A user error is an error caused by the programmer.
There are two types of user errors:
Providing illegal input to the interface, that is, providing input that's never accepted and is considered malformed regardless of the current state.
In the case where the interface user has sole ownership of the state: Providing input to the interface that is invalid in the current state.
Many interface contracts may not report user errors and instead choose the route of undefined behaviour with a potentially poisonous outcome. Check the policy of a specific interface for confirmation.
A perfect type system would remove the need for user errors to ever be reported at runtime and instead be caught at compile-time.
Parameters
message: any
cause: any
Returns Error
Example
constsqrt = (x) => { if (x < 0) { throwuser_error("x must be non-negative"); }
A user error is an error caused by the programmer.
There are two types of user errors:
Many interface contracts may not report user errors and instead choose the route of undefined behaviour with a potentially poisonous outcome. Check the policy of a specific interface for confirmation.
A perfect type system would remove the need for user errors to ever be reported at runtime and instead be caught at compile-time.