From 54508d87c354bc16819dbf5d49aeecf600c89e53 Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Wed, 24 Feb 2016 15:36:47 +0100 Subject: [PATCH] base_cpp: added exceptions when errors dependent on user input occur --- base_cpp/src/mutex.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/base_cpp/src/mutex.cc b/base_cpp/src/mutex.cc index be387f1..f340709 100644 --- a/base_cpp/src/mutex.cc +++ b/base_cpp/src/mutex.cc @@ -32,7 +32,10 @@ namespace base { namespace internal { 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() { @@ -40,7 +43,10 @@ MutexBase::~MutexBase() { } 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() { @@ -49,7 +55,10 @@ bool MutexBase::TryLock() { } 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 -- libgit2 0.26.0