File.makeCopy错误 [英] File.makeCopy error
问题描述
我正在使用以下代码来复制文件:
I am using the following code to make a copy of a file:
var backupFolder = DriveApp.getFolderById('1vOnO5aSOSFNWtOLHuAz4Lv2lsRgBwBpS');
var file = DriveApp.getFileById('1TJ_5Khw7wcqlIfbZ_-KLOQ-DsU02FsoRFYR1A3B4qAs');
file.makeCopy(file.getName(), backupFolder);
大部分时间没有问题.
有时会出现以下错误:
很抱歉,发生服务器错误.请稍等,然后重试
We're sorry, a server error occurred. Please wait a bit and try again
有人知道我如何获得更有意义的错误消息以了解问题所在吗?
Does anyone know how I can get a more meaningful error message to understand what is the issue?
推荐答案
要以安东和南希的答案为基础,我发现了一种用于记录错误并捕获重要问题的有用方法,就是将错误附加到Google工作表中以供参考.时间戳记,并向我发送警告电子邮件,告知失败原因.这使我实例注意到某些不正确的情况,并帮助我跟踪问题.
To build on Anton's and Nancy's answers one useful approach I have found for error logging and catching important issues, is to append the error to a google sheet for reference with a timestamp and to send me a warning email with the failure reason. This gives me an instance notice something is not right, and helps me to keep track of issues.
function someImportantProcess(){
var ss = SpreadsheetApp.getActiveSpreadSheet();
var sheet = ss.getSpreadsheetByName('Sheet1');
try {
someImportant function(){
Logger.log('important stuff')
}
} catch(e){
sheet.appendRow([timestamp, e])
sendEmail(e)
}
}
sendEmail(e){
var subject = '[Important a script failed]';
var body = e;
sendEmail(myemail@google.com, subject, body);
}
这篇关于File.makeCopy错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!