monkeylearn / monkeylearn-ruby

Official Ruby client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Ruby apps.
MIT License
80 stars 14 forks source link

Please namespace your errors #22

Closed alechoey closed 2 years ago

alechoey commented 4 years ago

Currently monkeylearn-ruby exposes globally namespaced custom exceptions, which can cause unexpected conflicts.

For instance, if I define a generic RateLimitError with a custom parent class that I use to rescue throughout my app, my app will fail to boot with the following error.

bin/rails c
Running via Spring preloader in process 79146
Loading development environment (Rails 5.2.4.3)
[1] pry(main)> class CustomExceptionType < StandardError; end
=> nil
[2] pry(main)> class RateLimitError < CustomExceptionType; end
TypeError: superclass mismatch for class RateLimitError
from (pry):2:in `<main>'