Make use of trailing commas consistent

Trailing commas in multi-line arrays and hashes are a source of unnecessary noise in commits. I've tended to include the trailing comma, but realised that I was not entirely consistent. This fixes that.
Clean up error handling method in API