30#ifndef LUMIERA_ERROR_HPP_
31#define LUMIERA_ERROR_HPP_
45#define LERR_(_NAME_) lumiera::error::LUMIERA_ERROR_##_NAME_
64 :
public std::exception
77 Error (
string description=
""
79 Error (std::exception
const& cause
80 ,
string description=
""
90 what () const noexcept override;
133 desc_.insert (0, text);
197 : PAR{description,
id? id:eID}
200 ,std::string description=
""
202 : PAR{cause, description,
id? id:eID}
267#define ERROR_LOG_AND_IGNORE(_FLAG_,_OP_DESCR_) \
268 catch (std::exception& problem) \
270 CStr errID = lumiera_error(); \
271 WARN (_FLAG_, "%s failed: %s", _OP_DESCR_, problem.what()); \
272 TRACE (debugging, "Error flag was: %s", errID);\
276 CStr errID = lumiera_error(); \
277 ERROR (_FLAG_, "%s failed with unknown exception; " \
278 "error flag is: %s" \
279 , _OP_DESCR_, errID?errID:"??"); \
282#define ERROR_LOG_AND_RETHROW(_FLAG_,_OP_DESCR_) \
283 catch (std::exception& problem) \
285 CStr errID = lumiera_error(); \
286 WARN (_FLAG_, "%s failed: %s", _OP_DESCR_, problem.what()); \
287 TRACE (debugging, "Error flag was: %s", errID); \
292 CStr errID = lumiera_error(); \
293 ERROR (_FLAG_, "%s failed with unknown exception; " \
294 "error flag is: %s" \
295 , _OP_DESCR_, errID?errID:"??"); \
305#define ON_EXCEPTION_RETURN(_VAL_,_OP_DESCR_) \
306 catch (std::exception& problem) \
308 CStr errID = lumiera_error(); \
309 WARN (stage, "%s (Handler) failed: %s", \
310 _OP_DESCR_, problem.what()); \
311 TRACE (debugging, "Error flag was: %s", errID); \
316 CStr errID = lumiera_error(); \
317 ERROR (stage, "(Handler) %s failed with " \
318 "unknown exception; error flag is: %s" \
319 , _OP_DESCR_, errID?errID:"??"); \
332#define LUMIERA_NOBUG_LOCATION \
333 std::string (NOBUG_BASENAME(__FILE__)) +":"+ NOBUG_STRINGIZE(__LINE__) + ", function " + __func__
335 lumiera::error::assertion_terminate (LUMIERA_NOBUG_LOCATION);
Interface and Base definition for all Lumiera Exceptions.
const string cause_
description of first exception encountered in the chain
string const & getUsermsg() const noexcept
extract the message to be displayed for the user
Error & prependInfo(string const &text) noexcept
give additional developer info.
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
string desc_
detailed description of the error situation for the developers
Error(Error const &)=default
virtual ~Error() noexcept
static const string extractCauseMsg(std::exception const &) noexcept
lumiera_err const id_
an LUMIERA_ERROR id, which is set as errorstate on construction
Error & operator=(Error &&)=delete
lumiera_err getID() const noexcept
the internal Lumiera-error-ID (was set as C-errorstate in ctor)
string const & rootCause() const noexcept
If this exception was caused by a chain of further exceptions, return the description of the first on...
string what_
buffer for generating the detailed description on demand
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.
Derived specific exceptions within Lumiera's exception hierarchy.
LumieraError(std::string description="", lumiera_err const id=eID) noexcept
LumieraError(std::exception const &cause, std::string description="", lumiera_err const id=eID) noexcept
lumiera_err lumiera_error(void)
Get and clear current error state.
Lumiera error handling (C interface).
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Helper to use a single extension point for specialised hash functions.
This header is for including and configuring NoBug.
void assertion_terminate(const string &location)
throw an error::Fatal indicating "assertion failure"
LumieraError< LERR_(STATE)> State
void lumiera_unexpectedException() noexcept
global function for handling unknown exceptions encountered at functions declaring not to throw this ...
void install_unexpectedException_handler()
install our own handler for undeclared exceptions.
LumieraError< LERR_(FLAG), State > Flag
LumieraError< LERR_(LOGIC)> Logic
LumieraError< LERR_(CONFIG), Invalid > Config
LumieraError< LERR_(EXTERNAL)> External
Lumiera public interface.
void throwOnError()
Check the lumiera error state, which maybe was set by C-code.
void maybeThrow(string description="")
Check the lumiera error state and throw a specific exception in case a non-cleared errorflag is detec...