Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
catchError((err: Error) =>
throwError(new HttpError(err.message, HttpStatus.BAD_REQUEST))
),
catchError((error: IOError) => throwError(
new HttpError(error.message, HttpStatus.BAD_REQUEST, error.data, error.context),
)),
)
(error: HttpError) => {
expect(error.message).toEqual('Validation error');
expect(error.status).toEqual(HttpStatus.BAD_REQUEST);
expect(error.context).toEqual('headers');
expect(error.data).toEqual([
{
expected: '"application/json"',
got: '"text/plain"',
path: 'content-type',
}
]);
done();
},
);
catchError(() => throwError(
new HttpError('Request body parse error', HttpStatus.BAD_REQUEST),
))
),
catchError((err: Joi.ValidationError) => {
const message = err.details[0].message;
return throwError(new HttpError(message, HttpStatus.BAD_REQUEST));
})
)