add email notifications on error

This commit is contained in:
Collin M. Barrett 2017-01-30 13:32:23 -06:00
parent 17b0c0e7cc
commit ac797132ae

View file

@ -436,9 +436,14 @@ function refreshHttpResponses(triggerNum) {
var url = rangeData.getCell(i - 1, 1).getValue();
if (url) {
try {
rangeStatus.setValue(UrlFetchApp.fetch(url).getResponseCode());
var urlStatus = UrlFetchApp.fetch(url).getResponseCode();
rangeStatus.setValue(urlStatus);
if (urlStatus != 200) {
MailApp.sendEmail("cb+flnotice" + "@collinmbarrett.com", urlStatus + ": " + url, urlStatus + ": " + url);
}
} catch (err) {
rangeStatus.setValue(err.message);
MailApp.sendEmail("cb+flnotice" + "@collinmbarrett.com", "Error: " + url, "Error: " + url + "<br>" + err.message);
}
}
}