a list of parameters describing the error
typically the arguments
variable at the callpoint
the name of the function at the callpoint
an explanation of the error
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.
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.