39 #ifndef LUMIERA_ERROR_HPP_ 40 #define LUMIERA_ERROR_HPP_ 42 #define _STDBOOL_H // prevent <atomic> from including stdbool.h 52 #define LERR_(_NAME_) lumiera::error::LUMIERA_ERROR_##_NAME_ 57 using CStr =
const char*;
72 :
public std::exception
74 lumiera_err
const id_;
82 virtual ~
Error () noexcept { };
85 Error (
string description=
"" 86 ,lumiera_err
const id =LERR_(EXCEPTION)) noexcept;
87 Error (std::exception
const& cause
88 ,
string description=
"" 89 ,lumiera_err
const id =LERR_(EXCEPTION)) noexcept;
98 what ()
const noexcept
override;
141 desc_.insert (0, text);
148 extractCauseMsg (std::exception
const&) noexcept;
166 void lumiera_unexpectedException () noexcept;
169 void assertion_terminate (
const string& location);
198 template<lumiera_err const& eID,
class PAR =Error>
204 ,lumiera_err
const id=eID) noexcept
205 : PAR{description,
id? id:eID}
208 ,std::string description=
"" 209 ,lumiera_err
const id=eID) noexcept
210 : PAR{cause, description,
id? id:eID}
226 void install_unexpectedException_handler();
262 throw EX (
error::Flag{error::detailInfo(), errorFlag}
275 #define ERROR_LOG_AND_IGNORE(_FLAG_,_OP_DESCR_) \ 276 catch (std::exception& problem) \ 278 const char* errID = lumiera_error(); \ 279 WARN (_FLAG_, "%s failed: %s", _OP_DESCR_, problem.what()); \ 280 TRACE (debugging, "Error flag was: %s", errID);\ 284 const char* errID = lumiera_error(); \ 285 ERROR (_FLAG_, "%s failed with unknown exception; " \ 286 "error flag is: %s" \ 287 , _OP_DESCR_, errID?errID:"??"); \ 290 #define ERROR_LOG_AND_RETHROW(_FLAG_,_OP_DESCR_) \ 291 catch (std::exception& problem) \ 293 const char* errID = lumiera_error(); \ 294 WARN (_FLAG_, "%s failed: %s", _OP_DESCR_, problem.what()); \ 295 TRACE (debugging, "Error flag was: %s", errID); \ 300 const char* errID = lumiera_error(); \ 301 ERROR (_FLAG_, "%s failed with unknown exception; " \ 302 "error flag is: %s" \ 303 , _OP_DESCR_, errID?errID:"??"); \ 313 #define ON_EXCEPTION_RETURN(_VAL_,_OP_DESCR_) \ 314 catch (std::exception& problem) \ 316 const char* errID = lumiera_error(); \ 317 WARN (stage, "%s (Handler) failed: %s", \ 318 _OP_DESCR_, problem.what()); \ 319 TRACE (debugging, "Error flag was: %s", errID); \ 324 const char* errID = lumiera_error(); \ 325 ERROR (stage, "(Handler) %s failed with " \ 326 "unknown exception; error flag is: %s" \ 327 , _OP_DESCR_, errID?errID:"??"); \ 340 #define LUMIERA_NOBUG_LOCATION \ 341 std::string (NOBUG_BASENAME(__FILE__)) +":"+ NOBUG_STRINGIZE(__LINE__) + ", function " + __func__ 342 #define NOBUG_ABORT \ 343 lumiera::error::assertion_terminate (LUMIERA_NOBUG_LOCATION); 347 #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.