rhodonite
    Preparing search index...

    Class RnException<ErrObj>

    Custom exception class for Rhodonite framework errors. This class extends the standard Error class to provide enhanced error handling with structured error information from RnError objects.

    const rnError: RnError<string> = {
    message: "Operation failed",
    error: "Invalid parameter"
    };
    const exception = new RnException(rnError);
    throw exception;

    Type Parameters

    • ErrObj

      The type of the error object contained within the RnError

    Hierarchy

    • Error
      • RnException
    Index

    Constructors

    Properties

    Methods

    Constructors

    • Creates a new RnException instance.

      Type Parameters

      • ErrObj

        The type of the error object contained within the RnError

      Parameters

      • err: RnError<ErrObj>

        The RnError object containing the error message and details

      Returns RnException<ErrObj>

      The constructor automatically formats the error message to include both the message and error details. If the error object contains a nested RnException, it will display "see below Exception ↓" followed by the nested exception's string representation.

    Properties

    _prefix: "\nRhodonite Exception" = '\nRhodonite Exception'

    Prefix string used in the exception name to identify Rhodonite exceptions

    Methods

    • Retrieves the original RnError object that was used to create this exception.

      Returns RnError<ErrObj>

      The RnError object containing the original error message and details

      try {
      // some operation that throws RnException
      } catch (error) {
      if (error instanceof RnException) {
      const originalError = error.getRnError();
      console.log(originalError.message);
      }
      }