mapbox / mapbox/mapbox-sdk-rb

Error Granularity

Open
#42 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
59
Forks
29
PR merge metrics
No merged PRs in 30d

Description

I am trying to use this gem as a replacement to [Geocoder](https://github.com/alexreisner/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](https://github.com/mapbox/mapbox-sdk-rb/blob/master/lib/mapbox/authentication_error.rb#L2) you'll see a class called `MapboxError`, which inherits from `StandardError`. Can we replace all the instances of `StandardError` with `MapboxError` in [this file](https://github.com/mapbox/mapbox-sdk-rb/blob/master/lib/mapbox.rb)? 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/mapbox.rb and compare its error handling with lib/mapbox/authentication_error.rb, which defines MapboxError. Review each StandardError instance in lib/mapbox.rb and determine whether it represents an SDK error. Done means the relevant errors can be rescued through the MapboxError hierarchy without changing unrelated error handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.