How to catch UrlFetchApp.fetch exception

前端 未结 4 725
孤街浪徒
孤街浪徒 2020-12-18 19:26

Is there any way to catch the exception from UrlFetchApp.fetch?

I thought I can use response.getResponseCode() to check the response code,

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 19:55

    why don't you use try catch and handle the error in catch block

    try{
        //Your original code, UrlFetch etc
      }
      catch(e){
        // Logger.log(e);
        //Handle error e here 
        // Parse e to get the response code
      }
    

提交回复
热议问题