Replies: 3 comments 2 replies
-
|
An abstract example of what I meant: class ApplicationService
include ServiceActor::Base
argument_error_class(MyCustomErrorForService::ArgumentError)
failure_class(MyCustomErrorForService::Failure)
endclass ApplicationForm
include ServiceActor::Base
argument_error_class(MyCustomErrorForForm::ArgumentError)
failure_class(MyCustomErrorForForm::Failure)
end |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Prototype: afuno@7bd4723 Example: module MyCustomErrorForService
class ArgumentError < ServiceActor::ArgumentError; end
class Failure < ServiceActor::Failure; end
endclass ApplicationService
include ServiceActor::Base
define_argument_error_class(MyCustomErrorForService::ArgumentError)
define_failure_class(MyCustomErrorForService::Failure)
endclass PayService < ApplicationService
input :order, type: String, allow_nil: false
play :pay_order
private
def pay_order
fail!("Can't pay for an order!")
end
endPayService.call(order: nil) |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Added to v3.3.0 🎉 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@sunny What do you think about allowing (for example) the Rails side of the application to specify custom classes for
raisethat are used inside the gem?For what? This idea came to my mind when I was trying to separate the use of Actor into services and forms. For example, there are two base classes:
In this case, need to somehow catch errors from child classes. And now it will all be either
ServiceActor::ArgumentErrororServiceActor::Failure.Would like to prepare two custom classes on the Rails side and pass them inside the gem to
ApplicationServiceandApplicationForm.Beta Was this translation helpful? Give feedback.
All reactions