Flickr-Foundation / flickr-photos-api

Look up information about photos and collections of photos from Flickr
Apache License 2.0
0 stars 0 forks source link

Improve the error handling through the library #49

Closed alexwlchan closed 2 months ago

alexwlchan commented 2 months ago

This started when I noticed that flickr.galleries.getListForPhoto returns error code 1 if you don't pass any arguments, which would throw a ResourceNotFound error. That's bad!

$ flapi flickr.galleries.getListForPhoto
<?xml version="1.0" encoding="utf-8"?>
<rsp stat="fail">
  <err code="1" msg="Required parameter missing"/>
</rsp>

I started looking at how best to do this, and realised that having all the exception mapping code inside the base API was bad – now I've pushed it out into the individual methods, which allows me to write more human-readable error messages, and keep all the error code mapping for each API method in one place. 💪