alexschneider/pushbullet-js — pull request #9 by dcormier (2014-12-01 01:47:18+00:00)
Title: Now always return an object from calls to the PushBullet APIs, even for errors

Previously, an error response from the PushBullet API would have resulted in a modified JSON string that could not be parsed as JSON (Chrome 39, beta) being returned to the caller. Now it returns an object with an "error" property, the value of which is the parsed error object from PushBullet. If no JSON error was returned from PushBullet, there will at least be a "response" property with the raw value of the AJAX response (if any). Additionally, an "httpStatus" property will be present in the object returned (or thrown) to the caller when the HTTP status code is !== 200.

This allows callers to pushbullet.js to display PushBullet's nice friendly error messages to their users, rather than a messy string that's basically JSON with an HTTP status code tacked on the front of it.