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
@gregcotten This happens because the actual try await self.save() does not fail. It is the wrapping transaction that fails, and therefore just causes a ROLLBACK and propagates the error up the chain. The middleware is not aware of any code that happens after your call to .save(). The only errors you would be able to catch are errors from other middlewares or actual errors thrown inside the Fluent create function.
Now whether this behaviour should be changed for transactions, I am not sure about. Let's ask @gwynne
Hi there! Using Vapor 4.54.0 and Fluent 4.4.0
I'm having an issue with
AsyncModelMiddleware
and perhaps justModelMiddleware
in general.For simplicity, I've reproduced the issue in the template app that you get from
vapor new
Inside Todo.swift:
In routes:
I made sure to add the middleware in the configure step:
Unfortunately my assertion in TodoMiddleware always fails (no error gets thrown). Is there something I am missing, or is this expected behavior?
The text was updated successfully, but these errors were encountered: