30 #ifndef LUMIERA_ERROR_HPP_ 31 #define LUMIERA_ERROR_HPP_ 33 #define _STDBOOL_H // prevent <atomic> from including stdbool.h 43 #define LERR_(_NAME_) lumiera::error::LUMIERA_ERROR_##_NAME_ 48 using CStr =
const char*;
63 :
public std::exception
65 lumiera_err
const id_;
73 virtual ~
Error () noexcept { };
76 Error (
string description=
"" 77 ,lumiera_err
const id =LERR_(EXCEPTION)) noexcept;
78 Error (std::exception
const& cause
79 ,
string description=
"" 80 ,lumiera_err
const id =LERR_(EXCEPTION)) noexcept;
89 what ()
const noexcept
override;
132 desc_.insert (0, text);
139 extractCauseMsg (std::exception
const&) noexcept;
157 void lumiera_unexpectedException () noexcept;
160 void assertion_terminate (
const string& location);
189 template<lumiera_err const& eID,
class PAR =Error>
195 ,lumiera_err
const id=eID) noexcept
196 : PAR{description,
id? id:eID}
199 ,std::string description=
"" 200 ,lumiera_err
const id=eID) noexcept
201 : PAR{cause, description,
id? id:eID}
217 void install_unexpectedException_handler();
253 throw EX (
error::Flag{error::detailInfo(), errorFlag}
266 #define ERROR_LOG_AND_IGNORE(_FLAG_,_OP_DESCR_) \ 267 catch (std::exception& problem) \ 269 const char* errID = lumiera_error(); \ 270 WARN (_FLAG_, "%s failed: %s", _OP_DESCR_, problem.what()); \ 271 TRACE (debugging, "Error flag was: %s", errID);\ 275 const char* errID = lumiera_error(); \ 276 ERROR (_FLAG_, "%s failed with unknown exception; " \ 277 "error flag is: %s" \ 278 , _OP_DESCR_, errID?errID:"??"); \ 281 #define ERROR_LOG_AND_RETHROW(_FLAG_,_OP_DESCR_) \ 282 catch (std::exception& problem) \ 284 const char* errID = lumiera_error(); \ 285 WARN (_FLAG_, "%s failed: %s", _OP_DESCR_, problem.what()); \ 286 TRACE (debugging, "Error flag was: %s", errID); \ 291 const char* errID = lumiera_error(); \ 292 ERROR (_FLAG_, "%s failed with unknown exception; " \ 293 "error flag is: %s" \ 294 , _OP_DESCR_, errID?errID:"??"); \ 304 #define ON_EXCEPTION_RETURN(_VAL_,_OP_DESCR_) \ 305 catch (std::exception& problem) \ 307 const char* errID = lumiera_error(); \ 308 WARN (stage, "%s (Handler) failed: %s", \ 309 _OP_DESCR_, problem.what()); \ 310 TRACE (debugging, "Error flag was: %s", errID); \ 315 const char* errID = lumiera_error(); \ 316 ERROR (stage, "(Handler) %s failed with " \ 317 "unknown exception; error flag is: %s" \ 318 , _OP_DESCR_, errID?errID:"??"); \ 331 #define LUMIERA_NOBUG_LOCATION \ 332 std::string (NOBUG_BASENAME(__FILE__)) +":"+ NOBUG_STRINGIZE(__LINE__) + ", function " + __func__ 333 #define NOBUG_ABORT \ 334 lumiera::error::assertion_terminate (LUMIERA_NOBUG_LOCATION); 338 #endif // LUMIERA_ERROR_HPP_ lumiera_err getID() const noexcept
the internal Lumiera-error-ID (was set as C-errorstate in ctor)
string desc_
detailed description of the error situation for the developers
void throwOnError()
Check the lumiera error state, which maybe was set by C-code.
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
This header is for including and configuring NoBug.
Lumiera error handling (C interface).
Derived specific exceptions within Lumiera's exception hierarchy.
lumiera_err const id_
an LUMIERA_ERROR id, which is set as errorstate on construction
lumiera_err lumiera_error(void)
Get and clear current error state.
Helper to use a single extension point for specialised hash functions.
string const & getUsermsg() const noexcept
extract the message to be displayed for the user
string const & rootCause() const noexcept
If this exception was caused by a chain of further exceptions, return the description of the first on...
const string cause_
description of first exception encountered in the chain
void maybeThrow(string description="")
Check the lumiera error state and throw a specific exception in case a non-cleared errorflag is detec...
Error & prependInfo(string const &text) noexcept
give additional developer info.
string what_
buffer for generating the detailed description on demand
Lumiera public interface.
string msg_
friendly message intended for users (to be localised)
Error & setUsermsg(string const &newMsg) noexcept
replace the previous or default friendly message for the user.
Interface and Base definition for all Lumiera Exceptions.