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
More of a discussion, as there are multiple ways to handle this but I quite like the way ActiveRecord rasies a RecordNotFound error message when performing find operations.
It's somewhat minor (and up for debate if this is the correct approach) but throwing a Clear::SQL namespaced error would allow me to add a generic handler for Clear::SQL::RecordNotFoundError in my parent API controllers and mean that I could skip guarding each of my update find methods with a method that checks for the presence of the model.
The main motivation for a more specific class is that catching NilAssertionError is too generic of an error to reliably assert behaviour upon.
More of a discussion, as there are multiple ways to handle this but I quite like the way ActiveRecord rasies a RecordNotFound error message when performing find operations.
It's somewhat minor (and up for debate if this is the correct approach) but throwing a Clear::SQL namespaced error would allow me to add a generic handler for
Clear::SQL::RecordNotFoundError
in my parent API controllers and mean that I could skip guarding each of my update find methods with a method that checks for the presence of the model.The main motivation for a more specific class is that catching NilAssertionError is too generic of an error to reliably assert behaviour upon.
clear/src/clear/model/modules/class_methods.cr
Lines 108 to 110 in bba7c6f
Could become something like:
If this is something you agree with and want to hand over to me, feel free to let me know and I'll raise a PR 😄
Ref: [1]
The text was updated successfully, but these errors were encountered: