简体   繁体   English

参数无效:名称-未知错误

[英]Invalid argument: name - unknown error

this is my first proper script on Google Scripts and I was going well until I hit a shortfall and ran into this error...! 这是我第一个在Google Scripts上使用的脚本,在遇到不足并遇到此错误之前,我一直做得很好。

Invalid argument: name (line 314, file "main", project "WallFeed")

Basically I have no idea what the error is as apparently its the following line which is highlighted as the error: 基本上我不知道该错误是什么,显然是将以下行突出显示为该错误:

  var LogSS = SpreadsheetApp.create(conf("LogNAME", null, null))

It seems like some kind of script formatting error in some regards but others not. 在某些方面似乎有些脚本格式化错误,而在其他方面则没有。

When I stop calling the function with the error its fine 当我停止错误调用函数时

Putting the whole code through a Javascript syntax checked - nothing 将整个代码通过Javascript语法检查-没有

Anyone seen this before? 有人看过吗?

Calling function 通话功能

function log(m) {

    LogFID = conf("LogFID", null, null)

    Logger.log("Opening log file: " + LogFID)

    // Try to open the log file
    try {
      log_file = DriveApp.getFileById(LogFID)

      if ( log_file.isTrashed() ) {
        throw new Error("File [" + LogFID + "] has been trashed! Creating a new log file")
      }

    } catch(e) {
      Logger.log(e.message)
      Logger.log(m)

      // Create a new log file
      create_log_file()

      // Log the error and original message
      log(e.message)
      log(m)

      return true
    }

    var lock = LockService.getPublicLock()
    if (lock.tryLock(10000))  {

       var ss = SpreadsheetApp.openById(LogFID)  
       var sheet = ss.getSheets()[0]

       var newRow = sheet.getLastRow() + 1      
       sheet.getRange(newRow, 1).setValue(Date())

       try {
         sheet.getRange(newRow, 2).setValue(m.toString())
       } catch(e) {
         Logger.log("Could not convert log to string: " + e.message)
         Logger.log(m)
         return false
       }

      sheet.autoResizeColumn(1)
      sheet.autoResizeColumn(2)

      lock.releaseLock()

    } else {
      Logger.log("Lock timeout for LogFID: " + LogFID)
      return false
    }

  return true

}

Called function where error occurs 发生错误的调用函数

function create_log_file() {

  // Create spreadsheet log file
  var LogSS = SpreadsheetApp.create(conf("LogNAME", null, null))
  LogFID = LogSS.getId()
  conf("LogFID", LogFID, false)

....etc

Not too keen to post my full code on here but I can share it with someone if they could take a look? 不太希望在此处发布我的完整代码,但是如果他们可以看的话,可以与他人分享?

TIA!! TIA!

Looks like this this is a deep Google Scripting error... I had two Google accounts joined when creating this script which messed things about. 看起来这是一个深层的Google脚本错误...创建此脚本时,我两个Google帐户合并在一起,使事情一团糟。 Basically I was writing the script in one account and running it another. 基本上,我是在一个帐户中编写脚本并在另一个帐户中运行脚本。 Strangely things like creating files was ok and they were created in the correct accounts Drive but other things obviously don't work when you have two accounts! 奇怪的是,诸如创建文件之类的事情没事,它们是在正确的帐户云端硬盘中创建的,但是当您有两个帐户时,其他事情显然不起作用!

UPDATE: This is actually not the case, the same type of error has raised it's head again, meaning I can't carry on coding...! 更新:实际上不是这种情况,相同类型的错误再次引起了人们的注意,这意味着我无法进行编码...! This time I rolled back to a known good version but the same error was there. 这次我回滚到了一个已知的好的版本,但是仍然存在相同的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM