"很抱歉,发生服务器错误.请稍等,然后重试"从自定义菜单运行函数时出错 [英] "We're sorry, a server error occurred. Please wait a bit and try again" error when running a function from a custom menu
问题描述
我已收到 341 封关于以下错误的错误通知电子邮件
I have received 341 error notification emails for the below error
很抱歉,发生服务器错误.请稍等,然后重试.
We're sorry, a server error occurred. Please wait a bit and try again.
通知电子邮件仅说明发生问题的函数名称.
The notification email only tells about the name of function in which the issue is occurring.
脚本现在没有运行.任何尝试运行脚本中的任何函数都会出现上述错误.我使用脚本添加到电子表格中的自定义菜单也不见了.我发现无法调试脚本,因为脚本上的每个操作都会给我上述错误.
The script is not running now. Any try to run any function in the script gave the above error. Also my custom menu that i have added into the Spreadsheet using the script is gone. I found no way to debug the script as every action on the script giving me the above error.
下面是出现错误的函数
function crunchEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var gLabel = sheet.getRange("gmailLabel").getValues();
// check the current SpreadSheet for limits and create a
// new SpreadSheet if limits are approaching
checkSpreadSheet();
var gFolder = sheet.getRange("outputFolderName").getValues();
var gSpreadSheetName = sheet.getRange("outputSpreadsheetPrefix").getValues();
var threadsPerSearch = sheet.getRange("threadsPerSearch").getValues();
// Number of emails per search:
var threads = GmailApp.search("-label:" + gLabel, 0, threadsPerSearch);
for (var x=0; x<threads.length; x++) {
var messages = threads[x].getMessages();
// getting null...a thread without messages is weird
if(messages != null) {
for (var y=0; y<messages.length; y++) {
updateSpreadSheet(messages[y]);
}
}
GmailApp.getUserLabelByName(gLabel).addToThread(threads[x]);
}
}
我被困在偏僻的地方,不知道为什么会这样?
I am stuck in the middle of nowhere, have no clue about why this is happening?
有人可以指导解决这个问题吗?
Could anyone please guide to resolve the issue?
推荐答案
问题已解决.
问题在于其他函数中的字符串替换函数.我正在使用带有正则表达式的字符串替换函数作为替换函数的输入.由于我收到上述错误,正则表达式不正确.
The problem is with string replace function in some other function. I am using the string replace function with regular expression as input to replace function. The regular expression was incorrect due which i am getting the above error.
这真的很奇怪,至少 GAS 应该给出一些正确的错误.
That's really weird, at least GAS should give some proper error.
这篇关于"很抱歉,发生服务器错误.请稍等,然后重试"从自定义菜单运行函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!