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)
end class 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
end class ApplicationService
include ServiceActor::Base
define_argument_error_class(MyCustomErrorForService::ArgumentError)
define_failure_class(MyCustomErrorForService::Failure)
end class PayService < ApplicationService
input :order, type: String, allow_nil: false
play :pay_order
private
def pay_order
fail!("Can't pay for an order!")
end
end PayService.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
-
@sunny What do you think about allowing (for example) the Rails side of the application to specify custom classes for
raise
that 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::ArgumentError
orServiceActor::Failure
.Would like to prepare two custom classes on the Rails side and pass them inside the gem to
ApplicationService
andApplicationForm
.Beta Was this translation helpful? Give feedback.
All reactions