consider better ways to deal with unexpected 404s
Opened this issue · 1 comments
katiecrane commented
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
.
DFurnes commented
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:
- Add
getOrFail()
method (like Laravel'sfindOrFail
) which throw aNotFoundException
when receiving a 404 status response from a GET request. - 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.