You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a similar issue, but a bigger issue here is that there is no way to allow the user to define their own error formatting.
The most obvious solution I found was to override handleError in the adapter and throw your own HttpErrors, but this is still limited to returning plain text with the HTTP status text forcibly prepended.
The best I could do was to define my own error type (for example, say: new HttpErrorWithBody(400, { error: { path: 'email', type: 'not_unique' } })), then catch that in my own onError handler and use it to return the statusCode and body on the error object. The problem with this is that onError isn't intended to be used this way, as right afterwards it proceeds to send the response body and status anyway—there's no way to disable this. One solution here would be to check res.headersSent after onError, but it just feels like a workaround to me.
There should probably be some way to define a function which is explicitly intended to format an error response. Perhaps something like this? (here I'm just replicating exactly the handling that is default today)
Context
From the example app, username is required.
API returns a 500 when trying to create a user without username.
Error
Expected
API should return a 400 instead of 500, with proper error handling like
The text was updated successfully, but these errors were encountered: