Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Error

This object contains helper functions related to throwing and catching errors (exceptions).

Hierarchy

  • Error

Index

Methods

Static deprecated

  • deprecated(message?: string, stackFrame?: number): void
  • If script warnings are enabled in the user preferences, prints a warning that a feature has been deprecated and may be removed in the future. The message often suggests what to use instead of the deprecated feature. If stackFrame is specified, it indicates the relative call site from which the warning will appear to have come. For example, if -2 (the default), the warning would appear to come from whatever function called the function that marked itself as deprecated (by calling this).

    If script warnings are not enabled, this has no effect.

    Parameters

    • Optional message: string

      details about the deprecation and possible workarounds

    • Optional stackFrame: number

      the relative position on the stack frame to report as the source of the warning

    Returns void

Static error

  • error(messageOrErrorOrThrowable?: any): void
  • Throws an error. If the argument is already an Error, it is thrown. If it is a Java exception (Throwable), a JS Error that wraps the exception is thrown. For any other object, an Error is thrown using the string value of the object as its error message.

    Parameters

    • Optional messageOrErrorOrThrowable: any

      an object to be converted into an Error and thrown

    Returns void

Static handleUncaught

  • handleUncaught(error: any): void
  • Prints a standard error message to the console to describe an exception. This function can be called to handle uncaught script errors in script code that outlives the execution of the script that defined it, such as an event listener or other Java interface implementation. For example:

    function irritableFunction() {
        if (--callsRemaining <= 0) {
            throw new Error("Arrrggh!");
        }
        println("Please stop!");
    }
    let button = new swing.JButton("Press Me!");
    button.addActionListener(function(event) {
        try {
            irritableFunction();
        } catch(ex) {
            Error.handleUncaught(ex);
        }
    });
    Eons.window.addCustomComponent(button);
    let callsRemaining = 3;

    Parameters

    • error: any

    Returns void

Static warn

  • warn(message?: string, stackFrame?: number): void
  • If script warnings are enabled in the user preferences, prints a warning with the specified message text. If stackFrame is specified, it indicates the relative call site from which the warning will appear to have come. For example, if -1 (the default), the warning would appear to come from whatever function called warn.

    If script warnings are not enabled, this has no effect.

    Parameters

    • Optional message: string

      the text of the warning

    • Optional stackFrame: number

      the relative position on the stack frame to report as the source of the warning

    Returns void