aboutsummaryrefslogtreecommitdiff
path: root/rng.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-09 21:43:38 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-09 21:43:38 +0200
commitcbea7bc041e5c14670042e3e52f0786f9561af05 (patch)
tree4d646978f1ed984099828a65c92bcee0a72b47dc /rng.cpp
parentd6dd94c63252ace898d9a60a539c7ab14d69f0ea (diff)
Better error handling (exceptions)
Diffstat (limited to 'rng.cpp')
-rw-r--r--rng.cpp4
1 files changed, 2 insertions, 2 deletions
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();