DoSomething/gateway

consider better ways to deal with unexpected 404s

Opened this issue · 1 comments

When we get a 404 on something other than a GET request, we would like a better way to deal with this. Currently we just return null.

I think the only place we'd want to handle 404s gracefully is probably a get() request, since the resource might legitimately just not be there. This was inspired by how Eloquent returns null for an empty query result, rather than throwing an exception.

Two improvements we could make:

  1. Add getOrFail() method (like Laravel's findOrFail) which throw a NotFoundException when receiving a 404 status response from a GET request.
  2. Make post(), put(), delete() all throw exceptions for 404s by default, since you'd rarely want to fail silently if you tried to update a resource and it wasn't actually there.