序列化继续Google Apps脚本时出现意外异常 [英] Unexpected exception upon serializing continuation Google Apps Script
问题描述
我最近开始在电子表格Google Apps脚本上尝试调试时发现错误继续序列化后的意外异常。在创建与Google CloudSQL API的连接后,该错误似乎开始了。即使在注释掉jdbc对象构造函数之后,仍会出现此错误。看来其他人已经遇到了这个问题,需要Google技术来解决这个问题。
我已经搜索了所有讨论板,找到了解决此问题的解决方案,但没有运气。任何可能有Google技术的人都可以在我的面前看一看?编辑:
好的,我想我已经发现了错误发生的地方。似乎是
var response = UrlFetchApp.fetch(url + nextPage,oauth_options);
在while循环中。
$ p $ 函数retrieveEvents(endTimeMinimum,updatedAfter,orderBy){
// var url = 'https://www.googleapis.com/calendar/v3/calendars/'+ source_cal +'/ events?key ='+ api_key +& futureevents = true& orderBy = updated& sortOrder = descending& updatedMin =+ last_sync_date_formated;
// var url ='https://www.googleapis.com/calendar/v3/calendars/'+ source_cal +'/ events?key ='+ api_key +& orderBy = updated& sortOrder = descending& amp ; updatedMin =+ last_sync_date_formated;
var url ='https://www.googleapis.com/calendar/v3/calendars/'+ source_cal +'/ events?key ='+ api_key +& singleEvents = true; ((orderBy!= null)&&(orderBy!=)){
url + =& orderBy =+ orderBy;
;
}
else url + =& orderBy = updated; ((updatedAfter!= null)&&(updatedAfter!=)){
url + =& updatedMin =+ updatedAfter;
;
}
else url + =& updatedMin =+ last_sync_dateTime;
//如果未指定endTimeMinimum,则将使用当前时间。
if(endTimeMinimum == null || endTimeMinimum ==){
endTimeMinimum = date_rfc339(Today);
}
url + =& timeMin =+ endTimeMinimum;
Logger.log(Request URL:+ url);
var largeString =;
var events = new Array();
var nextPage =;
var jsonObj
while(true){
var response = UrlFetchApp.fetch(url + nextPage,oauth_options);
largeString = response.getContentText(); ((largeString!= null)&&(largeString!=)){
jsonObj = JSON.parse(largeString);
if
}
if('jsonObj中的items')events = events.concat(jsonObj.items);
if('nextPageToken'in jsonObj){
nextPage =& pageToken =+ jsonObj.nextPageToken;
继续;
}
break;
}
if(events.length == 0)return null;
返回事件;
}
好的,所以我能够通过从主函数中的try catch块内调用的函数内移除try catch块来使问题消失。在调试器中运行程序时,我不再看到序列化继续时的意外异常。
我希望对导致此错误的原因有更确切的答案,如何改正它。
I recently started getting the error "Unexpected exception upon serializing continuation" on a spreadsheet Google Apps Script when trying to debug. The error seem to start after I created a connection to the Google CloudSQL api. This error still occurs even after commenting out the jdbc object constructor. It appears that others have had this issue and needed a Google Tech to resolve the issue.
I have searched all of the discussion boards for a solution to this issue with no luck. Any chance there is a Google tech out there who could take a look under the hood for me? I would post code if I could determine what line was actually triggering the error.
EDIT:
Ok, I think I have discovered where the error is occuring. Seems to be the
var response = UrlFetchApp.fetch(url + nextPage,oauth_options);
in the while loop. Here is the entire function code.
function retrieveEvents(endTimeMinimum, updatedAfter, orderBy){
//var url = 'https://www.googleapis.com/calendar/v3/calendars/' + source_cal + '/events?key=' + api_key + "&futureevents=true&orderBy=updated&sortOrder=descending&updatedMin=" + last_sync_date_formated;
//var url = 'https://www.googleapis.com/calendar/v3/calendars/' + source_cal + '/events?key=' + api_key + "&orderBy=updated&sortOrder=descending&updatedMin=" + last_sync_date_formated;
var url = 'https://www.googleapis.com/calendar/v3/calendars/' + source_cal + '/events?key=' + api_key + "&singleEvents=true";
if ((orderBy != null) && (orderBy != "")){
url += "&orderBy=" + orderBy;
}
else url += "&orderBy=updated";
if ((updatedAfter != null) && (updatedAfter != "")){
url += "&updatedMin=" + updatedAfter;
}
else url += "&updatedMin=" + last_sync_dateTime;
//if no endTimeMinimum is specified, the current time will be used.
if (endTimeMinimum == null || endTimeMinimum == ""){
endTimeMinimum = date_rfc339("Today");
}
url += "&timeMin=" + endTimeMinimum;
Logger.log("Request URL:" + url);
var largeString = "";
var events = new Array();
var nextPage = "";
var jsonObj
while(true){
var response = UrlFetchApp.fetch(url + nextPage,oauth_options);
largeString = response.getContentText();
if ((largeString != null) && (largeString != "")) {
jsonObj = JSON.parse(largeString);
}
if ('items' in jsonObj) events = events.concat(jsonObj.items);
if ('nextPageToken' in jsonObj){
nextPage = "&pageToken=" + jsonObj.nextPageToken;
continue;
}
break;
}
if (events.length == 0)return null;
return events;
}
OK, so I was able to make the problem go away by removing the try catch block inside a function that was called from inside a try catch block in the main function. I no longer am seeing the "Unexpected exception upon serializing continuation" when running the program from the debugger.
I wish I had a more solid answer on what causes this error and how to correct it.
这篇关于序列化继续Google Apps脚本时出现意外异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!