Skip to content

Error Granularity #42

@LexBartnicki

Description

@LexBartnicki

I am trying to use this gem as a replacement to Geocoder. In my application, if we have trouble communicating with Mapbox when making a request, we rescue that error and perform some fallback behavior.

Unfortunately, any error other than the AuthenticationError that is returned in this gem is a StandardError. So I am left to rescue StandardError which will rescue much more than any error communicating with Mapbox, most of which I would want it to not rescue.

Here you'll see a class called MapboxError, which inherits from StandardError. Can we replace all the instances of StandardError with MapboxError in this file? Then there will at least a catch-all for errors that are related to this SDK.

Eventually I'd hope we could get even more granular and have mapbox-sdk specific errors for every scenario, like they did in the Stripe SDK https://github.com/stripe/stripe-ruby/blob/master/lib/stripe/errors.rb. However, that can come later because for the majority of cases I would assume the difference between rescuing all mapbox-sdk errors and rescuing specific mapbox-sdk errors is a lot smaller than the difference between rescuing all mapbox-sdk errors and rescuing all errors that inherit from StandardError 😅

Please let me know how you want to proceed on this, I would love to hear about Mapbox's process for handling issues in their open-source SDKs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions