Error handling

Types

  • Luna::ErrCode

    The error code type represents one single error.

  • Luna::Error

    The error object encapsulates one error code along with one string that describes the error.

  • Luna::R

    A wrapper object for the return value of one function that may fail.

  • Luna::R< void >

    Specification of R for void type.

Alias types

  • using errcat_t = usize

    The error category type represents one container that can hold multiple error codes and sub-categories.

  • using RV = R

    An alias of R<void> for representing one throwable function with no return value.

Constants

  • constexpr RV ok

    A special constant result object that represents one successful result. You can return ok instead of RV() to clearly represent one successful call for one function without return value.

Functions

Macros

  • lupanic_if_failed(_res)

    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.

  • luerr

    The error code used in lucatch block to identify the error.

  • lutry

    Opens one try block that encapsulates expressions that may fail.

  • luthrow(_r)

    Throws one error and jumps execution to the lucatch block.

  • lucatch

    Opens one catch block that handles errors thrown from try block.

  • lucatchret

    Defines one catch block that returns the error code (if any) thrown from try block.

  • luexp(_exp)

    Tests whether the specified expression returns one failed result, and throws the error code if failed.

  • luset(_v, _exp)

    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.

  • lulet(_v, _exp)

    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.