Classes that manage messages and codes, which process message codes through static methods, Provides the ability to return messages or cause errors in a variety of ways.

Constructors

Properties

Methods

Constructors

Properties

$storage: object

Message code repository. This object uses the message code as a key to manage that message.

lang: string

Set the message language. Default is 'eng'. Setting this property changes the language used to return strings for message codes.

Methods

  • Use the message code to create an Error object and make an exception. Use the given message code to query the storage for string messages, Create an 'Error' object by replacing the placeholder in the message ('$1', '$2', ...) with the values provided.

    Parameters

    • code: string

      Message code.

    • value: string[]

      Values to replace the placeholder in the message.

    Returns Error

    created 'Error' object.

  • Returns the string using the message code. Use the given message code to query the storage for string messages, Returns the placeholder in the message ('$1', '$2', ...) replaced with the value provided.

    Parameters

    • code: string

      Message code.

    • value: string[]

      Values to replace the placeholder in the message.

    Returns string

    String for this message code.

    const message = Message.get('error_not_found', ['File']);
    console.log(message); // "Error: File not found"
  • Use the message code to generate console.warn. Use the given message code to query the storage for string messages, Replace the placeholder('$1','$2',...) in the message with the value provided and output it as 'console.warn'.

    Parameters

    • code: string

      Message code.

    • value: string[]

      Values to replace the placeholder in the message.

    Returns any

    Message.warn('deprecated_method', ['saveData']);
    // Logs: "Warning: The method 'saveData' is deprecated."