ExecutionError
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這個物件會針對嘗試透過 Apps Script API 執行指令碼函式而產生的錯誤性質提供相關資訊。如果 run
呼叫成功,但指令碼函式 (或 Apps Script 本身) 擲回例外狀況,則回應主體的 error
欄位會包含 Status
物件。Status
物件的 details
欄位包含一個陣列,其中包含其中一個 ExecutionError
物件。
JSON 表示法 |
{
"scriptStackTraceElements": [
{
object (ScriptStackTraceElement )
}
],
"errorMessage": string,
"errorType": string
} |
欄位 |
scriptStackTraceElements[] |
object (ScriptStackTraceElement )
這個物件陣列提供透過指令碼提供堆疊追蹤,以顯示執行失敗的位置,並且優先呼叫最深的呼叫。
|
errorMessage |
string
Apps Script 擲回的錯誤訊息,通常會翻譯成使用者的語言。
|
errorType |
string
錯誤類型,例如 TypeError 或 ReferenceError 。如果錯誤類型無法使用,就不包含這個欄位。
|
ScriptStackTraceElement
JSON 表示法 |
{
"function": string,
"lineNumber": integer
} |
欄位 |
function |
string
失敗的函式名稱。
|
lineNumber |
integer
指令碼執行失敗的行號。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eExecutionError\u003c/code\u003e objects provide information about errors during script execution via the Apps Script API.\u003c/p\u003e\n"],["\u003cp\u003eThese objects contain details such as stack trace elements, error message, and error type.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eScriptStackTraceElement\u003c/code\u003e objects offer a stack trace showing the location of the execution failure within the script.\u003c/p\u003e\n"],["\u003cp\u003eThey include the function name and line number where the error occurred.\u003c/p\u003e\n"]]],[],null,["# ExecutionError\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [ScriptStackTraceElement](#ScriptStackTraceElement)\n - [JSON representation](#ScriptStackTraceElement.SCHEMA_REPRESENTATION)\n\nAn object that provides information about the nature of an error resulting from an attempted execution of a script function using the Apps Script API. If a [run](/apps-script/api/reference/rest/v1/scripts/run#google.apps.script.v1.ScriptExecution.Execute) call succeeds but the script function (or Apps Script itself) throws an exception, the response body's [error](/apps-script/api/reference/rest/v1/scripts/run#body.Operation.FIELDS.error) field contains a [Status](/apps-script/api/reference/rest/v1/scripts/run#Status) object. The `Status` object's `details` field contains an array with a single one of these `ExecutionError` objects.\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"scriptStackTraceElements\": [ { object (/apps-script/api/reference/rest/v1/ExecutionError#ScriptStackTraceElement) } ], \"errorMessage\": string, \"errorType\": string } ``` |\n\n| Fields ||\n|------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `scriptStackTraceElements[]` | `object (`[ScriptStackTraceElement](/apps-script/api/reference/rest/v1/ExecutionError#ScriptStackTraceElement)`)` An array of objects that provide a stack trace through the script to show where the execution failed, with the deepest call first. |\n| `errorMessage` | `string` The error message thrown by Apps Script, usually localized into the user's language. |\n| `errorType` | `string` The error type, for example `TypeError` or `ReferenceError`. If the error type is unavailable, this field is not included. |\n\nScriptStackTraceElement\n-----------------------\n\nA stack trace through the script that shows where the execution failed.\n\n| JSON representation |\n|-------------------------------------------------------|\n| ``` { \"function\": string, \"lineNumber\": integer } ``` |\n\n| Fields ||\n|--------------|----------------------------------------------------|\n| `function` | `string` The name of the function that failed. |\n| `lineNumber` | `integer` The line number where the script failed. |"]]