Error handling
Types
-
The error code type represents one single error.
-
The error object encapsulates one error code along with one string that describes the error.
-
A wrapper object for the return value of one function that may fail.
-
Specification of R for void type.
Alias types
-
The error category type represents one container that can hold multiple error codes and sub-categories.
-
An alias of
R<void>
for representing one throwable function with no return value.
Constants
-
A special constant result object that represents one successful result. You can return
ok
instead ofRV()
to clearly represent one successful call for one function without return value.
Functions
-
ErrCode get_error_code_by_name(const c8 errcat_name, const c8 errcode_name)
Gets the error code represented by the error name.
-
errcat_t get_error_category_by_name(const c8 *errcat_name)
Gets the error category represented by the error category name.
-
const c8 * get_error_code_name(ErrCode err_code)
Fetches the name of the error code.
-
const c8 * get_error_category_name(errcat_t err_category)
Fetches the name of the error category.
-
errcat_t get_error_code_category(ErrCode err_code)
Fetches the error category that holds the error code.
-
Vector< errcat_t > get_all_error_categories()
Fetches all error categories registered in the system, including all subcategories.
-
Vector< ErrCode > get_all_error_codes_of_category(errcat_t err_category)
Fetches all error codes that belongs to the specified error category.
-
Vector< errcat_t > get_all_error_subcategories_of_category(errcat_t err_category)
Fetches all child error categories that belongs to the specified error category.
-
Gets the error object of this thread. Every thread will be assigned with one error object.
-
ErrCode set_error(ErrCode code, const c8 *fmt, VarList args)
Sets the error object of this thread.
-
ErrCode set_error(ErrCode code, const c8 *fmt,...)
Sets the error object of this thread.
-
const c8 * explain(ErrCode err_code)
Gets a brief description about the error code.
-
ErrCode unwrap_errcode(ErrCode err_code)
Gets the real error code if the error code is BasicError::error_object.
-
Tests if the result is successful and the return value is valid.
-
Constructs one successful result object with the specified return value.
-
Constructs one successful result object with the specified return value.
-
Constructs one failed result object with the specified error code.
-
Constructs one result object by coping from another result object.
-
Constructs one result object by moving from another result object.
-
Assigns the result object by coping from another result object.
-
Assigns the result object by moving from another result object.
-
Gets the return value of the result object.
-
Gets the return value of the result object.
-
Gets the error code of the result object.
-
Tests if the result is successful.
-
Constructs one successful result object.
-
Constructs one failed result object with the specified error code.
-
Constructs one result object by coping from another result object.
-
Assigns the result object by coping from another result object.
-
Gets the error code of the result object.
-
bool succeeded(const R< _Ty > &r)
Tests whether the specified result is successful.
-
bool failed(const R< _Ty > &r)
Tests whether the specified result is failed.
-
ErrCode unwrap_errcode(const R< _Ty > &obj)
Unwraps the real error code from the result.
Macros
-
Crashes the program if the specified result is failed.
-
lupanic_if_failed_msg(_res, _msg)
Crashes the program if the specified result is failed with custom message.
-
The error code used in
lucatch
block to identify the error. -
Opens one try block that encapsulates expressions that may fail.
-
Throws one error and jumps execution to the
lucatch
block. -
Opens one catch block that handles errors thrown from try block.
-
Defines one catch block that returns the error code (if any) thrown from try block.
-
Tests whether the specified expression returns one failed result, and throws the error code if failed.
-
Assigns the return value of the specified expression to the specified variable if the return value is valid, and throws the error code if not.
-
Creates one local variable to hold the return value of the specified expression if the return value is valid, and throws the error code if not.