How to handle urlfetch error? I'am trying muteHttpExceptions: true
, but it doesn't work and the script breaks.
function myFunction() {
var result = UrlFetchApp.fetch("http://www.soccer-wallpapers.net/soccer_wallpaper/barcelona_fc_barcelona_360.jpg ", {
muteHttpExceptions: true });
Logger.log("code: " + result.getResponseCode());
Logger.log("text: " + result.getContentText());
}
But I'm trying another error url to work fine.
http://img8.uploadhouse.com/fileuploads/2058/20586362b34151eb10a4001e1c44305fe41bff6.jpg
Solved handle using the try and catch method.
try
{
var page = UrlFetchApp.fetch("http://www.soccer-wallpapers.net/soccer_wallpaper/barcelona_fc_barcelona_360.jpg");
}
catch(err)
{
Browser.msgBox("error");
}
}