• Given a function name, a list of arguments and a string for a reason, throw an error with a prescribed message. This function always throws an error. When provided a list of arguments, the error message displays them with a call to anyToString. Note that because of the way Javascript works, inside a lambda-function, it is impossible to provide a list of arguments.

    Parameters

    • config: {
          args: IArguments;
          fun_name: string;
          reason: string;
      }

      a list of parameters describing the error

      • args: IArguments

        typically the arguments variable at the callpoint

      • fun_name: string

        the name of the function at the callpoint

      • reason: string

        an explanation of the error

    Returns any

    Here's an example of usage inside a dummy insert function :

    function insert(aList, aValue) {
    return raiseError({ fun_name: "insert", args: arguments,
    reason: "there is a good reason for that" });
    }

    It provides the following message in case of error :

    Error: when calling insert((| |), 1) : there is a good reason for that
    at raiseError (file:///path/to/error.js:41:11)

    It is recommended to use return in a functional setting because the function probably returns something elsewhere inside its code (and it mollifies tsc), but it's not necessary in an imperative setting.