VLink  2.0.0
A high-performance communication middleware
exception.h File Reference

Thin final wrappers around the standard exception hierarchy used by VLink. More...

#include <exception>
#include <stdexcept>
#include "./macros.h"
Include dependency graph for exception.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  vlink::Exception::RuntimeError
 Generic runtime failure; thrown by the logger on kFatal messages. More...
 
class  vlink::Exception::OutOfRange
 Indicates an index or iterator that is outside the legal range. More...
 
class  vlink::Exception::InvalidArgument
 Indicates that a function received an argument with an invalid value. More...
 
class  vlink::Exception::LogicError
 Indicates a violated program logic precondition. More...
 
class  vlink::Exception::DomainError
 Indicates a value outside the mathematical domain of a function. More...
 
class  vlink::Exception::LengthError
 Indicates an attempt to exceed an implementation size limit. More...
 
class  vlink::Exception::RangeError
 Indicates an arithmetic range error. More...
 
class  vlink::Exception::OverflowError
 Indicates an arithmetic overflow. More...
 
class  vlink::Exception::UnderflowError
 Indicates an arithmetic underflow. More...
 
class  vlink::Exception::OperationCancelled
 Marker exception thrown when a cooperative cancellation request is observed. More...
 

Namespaces

 
 

Macros

#define VLINK_EXCEPTION_EXPORT   VLINK_EXPORT
 

Detailed Description

Thin final wrappers around the standard exception hierarchy used by VLink.

Each VLink exception type is a final subclass of the corresponding standard exception base and lives inside the vlink::Exception namespace to avoid clashing with application code. Constructors and what() are inherited verbatim; only OperationCancelled overrides what() with a fixed identifier string.

Class hierarchy
VLink class Standard base Typical usage
Exception::RuntimeError std::runtime_error Generic runtime failure (logger fatal)
Exception::OutOfRange std::out_of_range Index or iterator out of bounds
Exception::InvalidArgument std::invalid_argument Bad function argument
Exception::LogicError std::logic_error Violated precondition
Exception::DomainError std::domain_error Value outside the function domain
Exception::LengthError std::length_error Exceeded implementation limit
Exception::RangeError std::range_error Arithmetic range error
Exception::OverflowError std::overflow_error Arithmetic overflow
Exception::UnderflowError std::underflow_error Arithmetic underflow
Exception::OperationCancelled std::exception Cooperative cancellation observed
Note
Logger throws Exception::RuntimeError whenever a kFatal message is emitted. The logger flushes all sinks before throwing so the application can catch the exception and shut down cleanly.
Example
try {
VLOG_F("Critical failure: ", reason);
} catch (const vlink::Exception::RuntimeError& e) {
std::cerr << e.what() << "\n";
shutdown_cleanup();
}
#define VLOG_F(...)
Definition: logger.h:791

Macro Definition Documentation

◆ VLINK_EXCEPTION_EXPORT

#define VLINK_EXCEPTION_EXPORT   VLINK_EXPORT