Skip to content

Commit

Permalink
Throw errors when the request failed
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ng-d committed Dec 10, 2021
1 parent 023bee5 commit 0aac826
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ export function getValues(gsheet, sheet) {
var dataString = NSString.alloc().initWithData_encoding(response, NSUTF8StringEncoding);

try {
return JSON.parse(dataString)
if (dataString.indexOf('{"error":"Unable to parse range:') == -1) {
return JSON.parse(dataString)
} else {
throw new Error("Something went badly wrong!")
}
} catch(e) {
sketch.UI.alert('Something went wrong with your spreadsheet', 'Check your internet connection or your spreadsheet format 🔥');
return null
sketch.UI.alert('Something went wrong with your spreadsheet', 'Check your internet connection or the sheet name');
throw new Error("Something went badly wrong!")
};

};
Expand Down

0 comments on commit 0aac826

Please sign in to comment.