尝试Catch don不能正常工作

时间:2015-05-12 10:20:50

标签: google-apps-script try-catch

我,如果它不存在,我可以创建一个文件夹,并且我使用try / catch但是几天前已停止工作。这是代码。非常感谢。

try {
var folders = alumnospath.getFolders();
while (folders.hasNext()) {
 var folderp = folders.next();
 var folderalumno = folderp.getName();
 if (folderalumno == alumno2) {
 var folderid = folderp.getId();
 var folder = DriveApp.getFolderById(folderid);}}}
catch (e){
var foldere = DriveApp.getFolderById(alumnospathid).createFolder(alumno2).getId();
var folder = alumnospath.getFolderById(foldere);} 

catch (e){
var foldere = DriveApp.getFolderById(alumnospathid).createFolder(alumno2).getId();
var folder = alumnospath.getFolderById(foldere);}
folder.createFile(pdf);

错误是(从西班牙语翻译):TypeError:不能调用方法" createFile"来自undefined。

问题是脚本在catch(e)中停止而不执行此操作。

1 个答案:

答案 0 :(得分:0)

Unless initMap = () -> require ['async!https://maps.googleapis.com/maps/api/js?libraries=places&sensor=true'], (maps) => mapOptions = center: {lat: 22.234376786, lng: 55.23243456456} zoom: 3 scrollwheel: false debugger map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions) is a variable of string type, then this line:

alumno2

will probably never evaluate as true, and therefore not get the file and folder ID.

if if (folderalumno == alumno2) { is the name of the folder you want, the code should be:

alumno2

put into quotes.