Commit 54508d87 by Marcus Winter

base_cpp: added exceptions when errors dependent on user input occur

parent 6a0eb53f
...@@ -32,7 +32,10 @@ namespace base { ...@@ -32,7 +32,10 @@ namespace base {
namespace internal { namespace internal {
MutexBase::MutexBase(int mutex_type) : mutex_() { MutexBase::MutexBase(int mutex_type) : mutex_() {
embb_mutex_init(&mutex_, mutex_type); int result = embb_mutex_init(&mutex_, mutex_type);
if (EMBB_SUCCESS != result) {
EMBB_THROW(ErrorException, "Could not initialize mutex.");
}
} }
MutexBase::~MutexBase() { MutexBase::~MutexBase() {
...@@ -40,7 +43,10 @@ MutexBase::~MutexBase() { ...@@ -40,7 +43,10 @@ MutexBase::~MutexBase() {
} }
void MutexBase::Lock() { void MutexBase::Lock() {
embb_mutex_lock(&mutex_); int result = embb_mutex_lock(&mutex_);
if (EMBB_SUCCESS != result) {
EMBB_THROW(ErrorException, "Could not lock mutex.");
}
} }
bool MutexBase::TryLock() { bool MutexBase::TryLock() {
...@@ -49,7 +55,10 @@ bool MutexBase::TryLock() { ...@@ -49,7 +55,10 @@ bool MutexBase::TryLock() {
} }
void MutexBase::Unlock() { void MutexBase::Unlock() {
embb_mutex_unlock(&mutex_); int result = embb_mutex_unlock(&mutex_);
if (EMBB_SUCCESS != result) {
EMBB_THROW(ErrorException, "Could not unlock mutex.");
}
} }
} // namespace internal } // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment