libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_exception.h File Reference

Go to the source code of this file.

Data Structures

struct  GblExceptionClass
 
struct  GblException
 

Macros

Type System

Type UUID and cast operators

#define GBL_EXCEPTION_TYPE
 
#define GBL_EXCEPTION(self)
 
#define GBL_EXCEPTION_CLASS(klass)
 
#define GBL_EXCEPTION_GET_CLASS(self)
 
DSL Macros

Macros for managing exceptions and control flow

Todo:
Implement
#define GBL_TRY
 
#define GBL_THROW(type, ...)
 
#define GBL_CATCH
 
#define GBL_CATCH_AS(type, name)
 

Functions

GblType GblException_type (void)
 
Static Methods

Static methods for managing a thread's active exception

GblExceptionGblException_current (void)
 
GblBool GblException_clear (void)
 
GblExceptionGblException_catch (GblType type)
 
void GblException_throw (GblException *pErr)
 

Detailed Description

GblException object-oriented error type.

This file contains the API for GblException, an extensible, object-oriented error type, similar to exceptions seen in languages such as C++, C#, and Java.

Unlike GblError, which is minimalistic and lightweight, GblException provides more flexibility for error data at the price of being heavier. It's better suited for errors which need to carry additional data payloads beyond just an error code and a message.

Todo:
  • consider making it a GblEvent and using event propagation to implement error filtering?
  • consider supporting child errors which become the children of a rethrown parent error
Author
2023 Falco Girgis

Definition in file gimbal_exception.h.

Macro Definition Documentation

◆ GBL_EXCEPTION_TYPE

#define GBL_EXCEPTION_TYPE

Type UUID for GblException.

Definition at line 34 of file gimbal_exception.h.

◆ GBL_EXCEPTION

#define GBL_EXCEPTION (   self)

Casts a GblInstance to GblException.

Definition at line 35 of file gimbal_exception.h.

◆ GBL_EXCEPTION_CLASS

#define GBL_EXCEPTION_CLASS (   klass)

Casts a GblClass to GblExceptionClass.

Definition at line 36 of file gimbal_exception.h.

◆ GBL_EXCEPTION_GET_CLASS

#define GBL_EXCEPTION_GET_CLASS (   self)

Retrieves a GblExceptionClass from a GblInstance.

Definition at line 37 of file gimbal_exception.h.

◆ GBL_TRY

#define GBL_TRY

Definition at line 45 of file gimbal_exception.h.

◆ GBL_THROW

#define GBL_THROW (   type,
  ... 
)

Definition at line 46 of file gimbal_exception.h.

◆ GBL_CATCH

#define GBL_CATCH

Definition at line 47 of file gimbal_exception.h.

◆ GBL_CATCH_AS

#define GBL_CATCH_AS (   type,
  name 
)

Definition at line 48 of file gimbal_exception.h.

Function Documentation

◆ GblException_type()

GblType GblException_type ( void  )

Returns the GblType UUID corresponding to GblException.

◆ GblException_current()

GblException * GblException_current ( void  )

Returns a pointer to the current thread's pending GblException or NULL if there isn't one.

◆ GblException_clear()

GblBool GblException_clear ( void  )

Clears the current thread's active GblException, returning GBL_TRUE if it had one.

◆ GblException_catch()

GblException * GblException_catch ( GblType  type)

Takes ownership of the current thread's active GblException if it matches type, otherwise returns NULL.

◆ GblException_throw()

void GblException_throw ( GblException pErr)

Sets the given GblException as the current thread's active exception, taking ownership of it.