mana icon indicating copy to clipboard operation
mana copied to clipboard

More descriptive errors on 403s

Open indexzero opened this issue 11 years ago • 1 comments

It is essential to know the status code when we get bad responses from APIs. Thanksfully DEBUG=mana:* helps :+1:

mana:artsy Starting request again to https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100 after back off attempt 1/3
mana:artsy Received an invalid statusCode (403) for URL https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100
mana:artsy Starting request again to https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100 after back off attempt 2/3
mana:artsy Received an invalid statusCode (403) for URL https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100
mana:artsy Starting request again to https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100 after back off attempt 3/3
mana:artsy Received an invalid statusCode (403) for URL https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100
mana:artsy Starting request again to https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100 after back off attempt 4/3
mana:artsy We failed to fetch https://api.artsy.net/api/v1/artist/faith-ringgold/artworks/all.json?page=1&size=100, all servers are down.
  Using node-artsy artist.artworkAll
    ✗ should return a list of artworks 
        » An unexpected error was caught: Error: Failed to process request: No more API endpoints available, everything is down 

indexzero avatar Sep 25 '14 02:09 indexzero

I'm pretty sure that there is an errors array in the returned error object which will contain this information. There errors contain all sorts of useful debug information including the status code, the url that was requested and much more:

https://github.com/3rd-Eden/mana/blob/master/index.js#L826-L833 https://github.com/3rd-Eden/mana/blob/master/index.js#L708-L721

3rd-Eden avatar Sep 25 '14 08:09 3rd-Eden