From cbea7bc041e5c14670042e3e52f0786f9561af05 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 9 Oct 2016 21:43:38 +0200 Subject: Better error handling (exceptions) --- rng.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rng.cpp') diff --git a/rng.cpp b/rng.cpp index e06b8be..fc86993 100644 --- a/rng.cpp +++ b/rng.cpp @@ -23,7 +23,7 @@ inline uint64_t rotr64(uint64_t x,uint32_t n){ KeyRng::KeyRng(const char *key_,int keylen_) :keylen(keylen_),idx(0),state(0){ - assert(keylen>0); + if(keylen<=0)throw invalid_argument("KeyRng: Key should not be empty"); assert(key_); key=new uint8_t[keylen]; memcpy(key,key_,keylen); @@ -32,7 +32,7 @@ KeyRng::KeyRng(const char *key_,int keylen_) KeyRng::KeyRng(const string &key_) :keylen(key_.size()),idx(0),state(0){ - assert(keylen>0); + if(keylen==0)throw invalid_argument("KeyRng: Key should not be empty"); key=new uint8_t[keylen]; memcpy(key,key_.data(),keylen); stir(); -- cgit v1.2.3-70-g09d2