Skip to content

Commit 3ed8981

Browse files
committed
updated error handling
1 parent d732cff commit 3ed8981

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

hashing/ripemd_160.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <iomanip> /// For functions like std::setw, std::setfill
2929
#include <iostream> /// For managing io
3030
#include <sstream> /// For bytes to hex string
31-
#include <stdexcept> /// For standard exceptions like std::runtime_error
31+
#include <stdexcept> /// For standard exceptions like std::invalid_argument
3232
#include <string> /// For string data
3333
#include <thread> /// To parallelize for efficiency
3434
#include <vector> /// For dynamic arrays
@@ -64,9 +64,9 @@ class RIPEMD160 {
6464
return (B & D) | (C & ~D);
6565
case 4:
6666
return B ^ (C | ~D);
67+
default:
68+
throw std::invalid_argument("j value out of bound");
6769
}
68-
69-
throw std::runtime_error("j value out of bound");
7070
}
7171

7272
/**
@@ -87,9 +87,9 @@ class RIPEMD160 {
8787
return static_cast<uint32_t>(0x8F1BBCDC);
8888
case 4:
8989
return static_cast<uint32_t>(0xA953FD4E);
90+
default:
91+
throw std::invalid_argument("j value out of bound");
9092
}
91-
92-
throw std::runtime_error("j value out of bound");
9393
}
9494

9595
/**
@@ -110,9 +110,9 @@ class RIPEMD160 {
110110
return 0x7A6D76E9;
111111
case 4:
112112
return 0x00000000;
113+
default:
114+
throw std::invalid_argument("j value out of bound");
113115
}
114-
115-
throw std::runtime_error("j value out of bound");
116116
}
117117

118118
/**

0 commit comments

Comments
 (0)