Permalink
Browse files

Catch JSON parse errors and propagate the exception

  • Loading branch information...
1 parent 33869ac commit 588ee90107903bb9e1f5356137beb1201d76f6ae @ianshward ianshward committed Nov 13, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 mandrill.js
View
@@ -36,7 +36,11 @@ function makeMandrill(key)
//everything is good!
if (format == 'json')
{
- body = JSON.parse(body);
+ try {
+ body = JSON.parse(body);
+ } catch (e) {
+ callback(e);
+ }
}
if (response['statusCode'] >= 200 && response['statusCode'] < 300)

0 comments on commit 588ee90

Please sign in to comment.