Skip to content

Instantly share code, notes, and snippets.

@ksuzushima
Created November 10, 2017 01:25
Show Gist options
  • Save ksuzushima/adcf98f1755a77ddc7b6ff2bd107da85 to your computer and use it in GitHub Desktop.
Save ksuzushima/adcf98f1755a77ddc7b6ff2bd107da85 to your computer and use it in GitHub Desktop.
Setting muteHttpExceptions to true in the HTTP request to suppress errors.
/**
* 備忘録
* @link https://stackoverflow.com/questions/31891694/handle-404-errors-in-urlfetchapp-fetch
*/
function fetchPage() {
var response = UrlFetchApp.fetch("http://ctrlq.org/404", {muteHttpExceptions: true});
if (response.getResponseCode() == 404) {
Logger.log("Web page not found");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment