API handling of fetching missing slugs

Hi,

I recently used beeminder gem and noticed a bug when trying to access unrecgonized slugs.
The gem throws the following exception:

RuntimeError: request failed: 500 / {"error":"You need to sign in or sign up before continuing."}

This error makes it hard to recognize the problem.
If the problem is lack of authorization the error code should be 401 or 403.
In the case of a valid auth token and just a missing resource, 404 is accurate.
This will allow easier handling of edge cases.
Ideally the gem will be able to raise only one of a fixed list of custom exceptions.

Thanks!

3 Likes