Skip to content

Commit

Permalink
Catch JSON parse errors and propagate the exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ianshward committed Nov 13, 2012
1 parent 33869ac commit 588ee90
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mandrill.js
Expand Up @@ -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)
Expand Down

0 comments on commit 588ee90

Please sign in to comment.