Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call for FService::Base #27

Open
MatheusRich opened this issue May 20, 2021 · 0 comments
Open

Add call for FService::Base #27

MatheusRich opened this issue May 20, 2021 · 0 comments
Labels
feature request New feature or request

Comments

@MatheusRich
Copy link
Contributor

call should be the safe version of the current run (and future call!). call should work pretty much like run does, but it also catches any StandardError that may be raised in its body and encapsulates as a failure:

class Bomb < FService::Base
  def call # safe
    raise StandardError, 'BOOOM!'
  end
end

Bomb.call # remember that Bomb.call == Bomb.new.call
# => #<Failure:uu1D @type=:exception @error=#<StandardError: BOOOM!>>

With call! (with bang), we have the unsafe version:

class Bomb < FService::Base
  def call! # unsafe
    raise StandardError, 'BOOOM!'
  end
end

Bomb.call # remember that Bomb.call == Bomb.new.call
# => BOOOM! (StandardError)
@MatheusRich MatheusRich added the feature request New feature or request label May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant