如何使用CalendarApp调试间歇性错误? [英] How do I debug intermittent errors with CalendarApp?

查看:91
本文介绍了如何使用CalendarApp调试间歇性错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google Apps脚本,它使用JSON网络API从站点获取星际争霸2锦标赛列表(使用UrlFetchApp),并在各种日历(每个地区/联盟组合的一个日历)中创建相应的Google日历活动。



我每5分钟设置一次触发器,当错误发送时立即发送电子邮件,如果脚本正常完成并添加了任何事件或遇到任何错误, ,它也会通过电子邮件发送给我。



大多数情况下,没有必要进行任何更改(我使用ScriptDb缓存JSON信息以避免向CalendarApp发出呼叫,除非需要)和脚本是沉默的。然而,隔夜我收到了几封包含这些信息的电子邮件:

 您请求的资源找不到。 (第154行)

服务错误:CalendarApp:错误正文{font-family:arial,sans-serif}
G oogle错误无法访问您请求的日历(第155行)

TypeError:无法调用null的方法getEvents。 (第155行)

154行,155行和156行是:

  var calendar = CalendarApp.getCalendarById(calendars [region] [league]); 
var events = calendar.getEvents(new Date(1900,1,1),new Date());
events.forEach(function(event){event.deleteEvent();});

此时脚本中我已经尝试添加任何新事件,查询我的每个日历以删除过去发生的任何事件。

这些错误似乎是CalendarApp可用性的一个问题,但信息中心并未表明该服务存在任何问题。



我的项目关键是: MWhWmFSrL1dK3RJui6Aphb12cA4KNgw7R

解决方案

他们所有人在执行过程中偶尔会出现错误,无论是手动模式还是时间触发,似乎(但我知道这是一种经验感觉),当服务流量过高时,此服务会出现错误或者互联网连接速度太慢(几个月前,我的办公室的互联网连接非常差,而且脚本用于产生很多的错误 - 而它的d idn't当从家里执行时,现在情况变得更好了,同样的脚本可以在任何地方顺利运行)。

无论如何,无论真正的原因是什么(并且只有一个Google工程师可以回答),我使用的解决方案是将日历调用放入try-catch循环中,尝试连接几次,然后我再也没有错误通知。



在另一个我没有更改的脚本中,我不时发现错误,但由于它不涉及重要信息,所以我并不介意......请注意,我现在就查看了,而我5天内没有收到任何通知! (一定是日历的好季节; - )

I have a Google Apps Script which uses a JSON web API to get a list of StarCraft2 tournaments from a site (using UrlFetchApp) and create corresponding Google Calendar events in a variety of Calendars (one Calendar per region/league combination).

I have a trigger set to every 5 minutes, that emails me immediately on errors, and if the script completes normally and has added any events or run into any errors I caught, it emails me as well.

Most of the time, there are no changes necessary (I cache the JSON info using ScriptDb to avoid calling out to CalendarApp unless I need to) and the script is silent. However, overnight I received several emails which contained the messages:

The resource you requested could not be located. (line 154)

Service error: CalendarApp: Error body {font-family: arial,sans-serif}
G o o g l e     Error   Cannot access the calendar you requested (line 155)

TypeError: Cannot call method "getEvents" of null. (line 155)

Lines 154, 155 and 156 are:

var calendar = CalendarApp.getCalendarById(calendars[region][league]);
var events = calendar.getEvents(new Date(1900, 1, 1), new Date());
events.forEach(function (event) { event.deleteEvent(); });

At this point in the script I've already attempted to add any new events and I'm about to query each of my Calendars to delete any events which occurred in the past.

These errors appear to be an issue with the availability of CalendarApp, but the Dashboard does not indicate any issues with the service.

My project key is: MWhWmFSrL1dK3RJui6Aphb12cA4KNgw7R

解决方案

I have many scripts that use CalendarApp and all of them have occasional errors in their execution, wether in manual mode or time triggered, it seems (but I know this is an empirical feeling) that this service is subject to errors when the traffic is too high or the internet connection is too slow (a few month ago my office had a very poor internet connection and the script used to generate a lot of errors -while it didn't when executed from home-, now that the situation is better the same script runs smoothly everywhere).

Anyway, whatever the real cause might be (and only a Google engineer could answer), the solution I used was to put the Calendar calls in a try-catch loop that tries the connection a few times and since then I have no error notification anymore.

On another script that I didn't change yet, I keep getting errors from time to time but since it doesn't concern critical information I don't really mind... note that I just checked right now and I haven't receive any notification for 5 days ! (must be a good season for calendars ;-)

这篇关于如何使用CalendarApp调试间歇性错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆