Skip to content

Commit

Permalink
fix: handle non-JSON-parse-able api responses
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Nov 9, 2021
1 parent 60d3997 commit 3c98668
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/services/geocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ export const geocode = async (event, { filePath, fields, apiKey, wkid = 26912 })
}).json();
} catch (error) {
log.error(`Error geocoding ${street} ${zone}: ${error}`);
response = JSON.parse(error.response.body);

try {
response = JSON.parse(error.response.body);
} catch (error) {
response = { error: error.message };
}

failures += 1;
}
Expand Down

0 comments on commit 3c98668

Please sign in to comment.