Creates a new class of Error for issues to be returned to users.
Using this error allows a web framework handler (e.g. express, next) to know it
is safe to return the message in a request. Other kinds of errors will
result in a generic 500 message to avoid the possibility of internal
exceptions being leaked to attackers.
In JSON requests, code will be an HTTP code and error will be a response body.
In streaming requests, { code, message } will be passed as the error message.
Creates a new class of Error for issues to be returned to users. Using this error allows a web framework handler (e.g. express, next) to know it is safe to return the message in a request. Other kinds of errors will result in a generic 500 message to avoid the possibility of internal exceptions being leaked to attackers. In JSON requests, code will be an HTTP code and error will be a response body. In streaming requests, { code, message } will be passed as the error message.