martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
405 stars 23 forks source link

Ensure debug server error handler displays error details in case of invalid record exceptions #123

Closed ellmetha closed 3 months ago

ellmetha commented 1 year ago

Description

By default, the Marten::Handlers::Defaults::Debug::ServerError handler (which is called when an unhandled exception is raised in development) displays only the message of the showcased exception, which does not help much in case of Marten::DB::Errors::InvalidRecord exceptions (which are raised when trying to save invalid model records).

Let's implement a special case in order to ensure that validation error details are surfaced for these exceptions in this debug page. In this light, we could probably iterate over the error set (instance of Marten::Core::Validation::ErrorSet) for the considered record and display for each error the corresponding field and message.