Class ScriptCancellationError

java.lang.Object
com.deltawalker.script.ScriptCancellationError

public final class ScriptCancellationError extends Object
The value an operation rejects with when it is cancelled, for instance because its comparison was closed while the operation was pending. Scripts receive it in the catch block of an await and can tell it from an ordinary failure by its cancelled property:

 try {
     await comp.compare();
 } catch (e) {
     if (e.cancelled) {
         console.log('Cancelled: ' + e.message);
     } else {
         console.error('Error: ' + e);
     }
 }
 

Ordinary failures reject with a plain string, for which e.cancelled is undefined.

Since:
3.0
See Also:
  • Field Details

    • cancelled

      public final boolean cancelled
      Always true. Scripts check e.cancelled to detect cancellation.
      See Also:
    • message

      public final String message
      Why the operation was cancelled, in plain text.
  • Method Details

    • toString

      public String toString()
      Returns message, so that 'Cancelled: ' + e reads well in scripts.
      Overrides:
      toString in class Object
      Returns:
      the cancellation message