Lumiera  0.pre.03
»edit your freedom«
error-exception.cpp File Reference

Go to the source code of this file.

Description

implementation of C++-style error handling.

This compilation unit defines a custom exception class hierarchy, and is tightly integrated with the C-style error handling.

See also
error-state.c
error.hpp

Definition in file error-exception.cpp.

#include "lib/error.hpp"
#include "include/lifecycle.h"
#include "lib/meta/util.hpp"
#include "lib/util.hpp"
#include <exception>
#include <typeinfo>
#include <iostream>

Functions

void assertion_terminate (const string &location)
 throw an error::Fatal indicating "assertion failure"
 
const string default_usermsg (Error *) noexcept
 the message shown to the user per default if an exception reaches one of the top-level catch clauses. More...
 
CStr detailInfo ()
 
void install_unexpectedException_handler ()
 install our own handler for undeclared exceptions. More...
 
 LUMIERA_ERROR_DEFINE (LOGIC, "internal logic broken")
 
 LUMIERA_ERROR_DEFINE (FATAL, "floundered")
 
 LUMIERA_ERROR_DEFINE (CONFIG, "misconfiguration")
 
 LUMIERA_ERROR_DEFINE (STATE, "unforeseen state")
 
 LUMIERA_ERROR_DEFINE (FLAG, "non-cleared lumiera errorstate")
 
 LUMIERA_ERROR_DEFINE (INVALID, "invalid input or parameters")
 
 LUMIERA_ERROR_DEFINE (EXTERNAL, "failure in external service")
 
 LUMIERA_ERROR_DEFINE (EXCEPTION, "generic Lumiera exception")
 
 LUMIERA_ERROR_DEFINE (ASSERTION, "assertion failure")
 
 LUMIERA_ERROR_DEFINE (LIFECYCLE, "Lifecycle assumptions violated")
 
 LUMIERA_ERROR_DEFINE (WRONG_TYPE, "runtime type mismatch")
 
 LUMIERA_ERROR_DEFINE (ITER_EXHAUST, "end of sequence reached")
 
 LUMIERA_ERROR_DEFINE (CAPACITY, "predefined fixed storage capacity")
 
 LUMIERA_ERROR_DEFINE (SAFETY_LIMIT, "exceeding fixed internal safety limit")
 
 LUMIERA_ERROR_DEFINE (INDEX_BOUNDS, "index out of bounds")
 
 LUMIERA_ERROR_DEFINE (BOTTOM_VALUE, "invalid or NIL value")
 
 LUMIERA_ERROR_DEFINE (UNCONNECTED, "missing connection")
 
 LUMIERA_ERROR_DEFINE (UNIMPLEMENTED,"using a feature not yet implemented....")
 
void lumiera_unexpectedException () noexcept
 global function for handling unknown exceptions encountered at functions declaring not to throw this kind of exception. More...
 
LifecycleHook schedule_ (ON_BASIC_INIT, &install_unexpectedException_handler)
 

Variables

std::terminate_handler nextHandler = nullptr
 

Namespaces

 lumiera
 Lumiera public interface.
 

Function Documentation

◆ default_usermsg()

const string lumiera::error::default_usermsg ( Error )
inlinenoexcept

the message shown to the user per default if an exception reaches one of the top-level catch clauses.

Todo:

to be localised

develop a framework to set more specific yet friendly messages

Definition at line 49 of file error-exception.cpp.

References lumiera::error::default_usermsg().

Referenced by lumiera::error::default_usermsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detailInfo()

CStr detailInfo ( )
Returns
error detail-info if currently set, a default message else

Definition at line 55 of file error-exception.cpp.

References lumiera::error::detailInfo(), and lumiera_error_extra().

Referenced by lumiera::error::detailInfo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lumiera_unexpectedException()

void lumiera_unexpectedException ( )
noexcept

global function for handling unknown exceptions encountered at functions declaring not to throw this kind of exception.

Basically, any such event can be considered a severe design flaw; we can just add some diagnostics prior to halting.

Definition at line 167 of file error-exception.cpp.

References cStr(), Error::getID(), Error::getUsermsg(), lumiera::error::lumiera_unexpectedException(), and Error::what().

Referenced by lumiera::error::install_unexpectedException_handler(), and lumiera::error::lumiera_unexpectedException().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: