Closed kettanaito closed 2 months ago
This is potentially solved by adding support for throwing Response.error()
(https://github.com/mswjs/interceptors/pull/563).
Not needed.
controller.errorWith()
will allow you to mock request errors explicitly (see #431).
Right now, there's no way to prevent an error from being coerces as a 500 error response. In some cases, like here, we do want to throw an error for it to error the request instead of producing an error response.
This adds a new
RequestError
class. If an instance ofRequestError
is thrown within a request listener, the respective request will error with the error thrown.Behavior-wise, this is similar to using
Response.error()
as a mocked response. The difference is that you can throwRequestError
anywhere in the request handling pipeline.