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
In exceptions, we can catch or a single error, or a family of errors, using its superclass...
Ex:
ClientError=Class.new(RuntimeError)UnprocessableEntity=Class.new(ClientError)Conflict=Class.new(ClientError)deffoocreate_userrescueUnprocessableEntity=>error"User can not be created fix errors and try again #{error.message}"rescueConflict"User already exist."rescueClientError=>errorSentry.capture_exception("Some unexpected client error happened: #{error.message}")"Unknow error happened, please contact system administration"end
Nowadays it is impossible in FService, because we can create a result using just one symbol....
If we are able to put more than one symbol, we could, for example, pass a specific symbol and a more generic one.
User::Create(attrs: {name: 'Joe'}).on_success(:created){return'User created'}.on_failure(:unprocessable_entity){ |error| return"User can not be created fix errors and try again #{error}"}.on_failure(:conflict){return"User already exist."}.on_failure(:client_error)doSentry.capture_exception("Some unexpected client error happened: #{error.message}")return"Unknow error happened, please contact system administration"end
The text was updated successfully, but these errors were encountered:
In exceptions, we can catch or a single error, or a family of errors, using its superclass...
Ex:
Nowadays it is impossible in FService, because we can create a result using just one symbol....
If we are able to put more than one symbol, we could, for example, pass a specific symbol and a more generic one.
Ex:
And the usage would be:
The text was updated successfully, but these errors were encountered: