Fix Error Response Handling

When trying to parse JSON we want to catch exceptions beside TypeError (e.g. ValueError when the given string is no valid JSON).

Also, the callback logic was broken.