Class ErrorFunctions

java.lang.Object
com.scriptbasic.utility.functions.ErrorFunctions

public class ErrorFunctions
extends java.lang.Object
  • Method Summary

    Modifier and Type Method Description
    static void asserT​(java.lang.String s, java.lang.Boolean b)
    Throw an exception causing BASIC runtime error if the assertion fails.
    static void error​(java.lang.String s)
    Throw an exception causing BASIC runtime error.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • error

      public static void error​(java.lang.String s) throws ScriptBasicException
      Throw an exception causing BASIC runtime error. This method can be called directly from BASIC to stop the interpreter with an error condition.
      Parameters:
      s - the message in the error
      Throws:
      ScriptBasicException - always
    • asserT

      public static void asserT​(java.lang.String s, java.lang.Boolean b) throws ScriptBasicException
      Throw an exception causing BASIC runtime error if the assertion fails. This can be used in the BASIC program to test preconditions and stop the execution of the BASIC program if the condition fails. For example you can write
       assert("test that the parameter starts with the required prefix", startsWith(s,prefix))
       

      In the example above if the variable s starts with the string contained in the variable prefix then the execution of the BASIC program goes on, otherwise the function causes BASIC runtime error.

      Parameters:
      s - parameter
      b - parameter
      Throws:
      ScriptBasicException - in case of exception