Open kratos-digital opened 1 week ago
What i recommend to you is to handle the error in laravel's error handler and to manually set the error into the session so inertia.js will receive it, this way the onError will trigger.
I don't know what you mean. I use form request authorized method (which runs before validation) and which should return true or false, not an error or exception. Handling authorization manually would make the built-in features useless
Take a look here at this example: https://github.com/wizzymore/inertia-errors-example
I am using form requests and when an action is not authorized I return false from
authorize()
method in the request.This renders the dialog with the message 403 Not authorized, but only onFinish event triggers.
The problem is when using dialogs (shadcn ui), even though the 403 dialog renders above the dialog with form, the focus is still on the dialog behind (maening you can't interact with 403 dialog until the one below is closed), and what I wanted to do with onError is to hide that dialog so the focus would be on 403.
But it seems none of the events is firing when there is any error response, other than validation errors (which returns 200 response and not an actual 422 Unprocessable Content error response). It seems onError triggers only when there is an error bag present in 200 response, and I think there is missing something to handle such response with proper events.