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

Request: Make exceptions subclass from a single parent class #332

Open
Roguelazer opened this issue Oct 8, 2024 · 0 comments
Open

Request: Make exceptions subclass from a single parent class #332

Roguelazer opened this issue Oct 8, 2024 · 0 comments

Comments

@Roguelazer
Copy link

Right now, if you want to handle exceptions, your choices are to thread through a block to every single function call, or to do weird import gymnastics to get at the hidden codegen modules.

If the various ApiError types all subclassed from a single public exception (something like Hubspot::BaseException), it'd be much more straightforward to use normal Ruby exception handling.

What I'm doing for now is basically

begin
  # do lots of hubspot stuff
rescue => exc
  raise exc unless exc.class.name.match?(/\AHubspot::.*ApiError\z/)
  # handle hubspot exceptions
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant