lulalala/adequate_errors

Non-Rails usage.

konung opened this issue · 7 comments

Hi.

Since this gem intercepts Rails errors, does it mean that it is is Rails only? Or can it be used in other settings, like my own gems or Roda/Sinatra/Hanami?

@konung strictly speaking, this gem is only related to model, not the overall web framework. If your model in Sinatra include ActiveModel::Validations then it should work.

What model class do you use? If it does not take too much time to port I may just do that.

Currently no, but I've asked dry-validations how they liked the idea of Error object.

For PORO model, there is no validations logic so I can't imagine what you want. Could you give some pseudo code as use case?

Ok, so the idea is to have the object catching errors, and have these errors stored in the Errors object.

It sounds useful because we no longer have to worry about error handling from the outside.

Currently AdequateErrors only handle what ActiveModel::Errors handles, that is the model validation errors. The general "Ruby Error" is not really handled here.

I do feel this use case is suitable for a different layer though, which is service objects. For example, in https://github.com/AaronLasseigne/active_interaction we can easily have these exceptions collected when we run it. It can then assign the Ruby Errors into its Errors object. That's one way to catch all errors during the run execution without user writing any rescue.

And after checking with developer of dry-validation, it has its own Error objects, which is accessible via Result#message_set method. It has a different philosophy to AdequateErrors, but still is better than just a bunch of strings.

Have a great day!

@lulalala Thank you for looking into it.