WebAssembly.CompileError
WebAssembly.CompileError 物件表示 WebAssembly 解碼或驗證期間發生的錯誤。
建構函式
WebAssembly.CompileError()-
建立一個新的
WebAssembly.CompileError物件。
例項屬性
WebAssembly.CompileError.prototype.message-
錯誤訊息。從
Error繼承。 WebAssembly.CompileError.prototype.name-
錯誤名稱。從
Error繼承。 WebAssembly.CompileError.prototype.cause-
錯誤原因。從
Error繼承。 WebAssembly.CompileError.prototype.fileName非標準-
引發此錯誤的檔案的路徑。從
Error繼承。 WebAssembly.CompileError.prototype.lineNumber非標準-
引發此錯誤的行號。從
Error繼承。 WebAssembly.CompileError.prototype.columnNumber非標準-
引發此錯誤的行中的列號。從
Error繼承。 WebAssembly.CompileError.prototype.stack非標準-
堆疊跟蹤。從
Error繼承。
例項方法
WebAssembly.CompileError.prototype.toString()-
返回表示指定
Error物件的字串。從Error繼承。
示例
建立新的 CompileError 例項
以下程式碼片段建立了一個新的 CompileError 例項,並將其詳細資訊記錄到控制檯。
js
try {
throw new WebAssembly.CompileError("Hello", "someFile", 10);
} catch (e) {
console.log(e instanceof CompileError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "CompileError"
console.log(e.fileName); // "someFile"
console.log(e.lineNumber); // 10
console.log(e.columnNumber); // 0
console.log(e.stack); // returns the location where the code was run
}
規範
| 規範 |
|---|
| WebAssembly JavaScript 介面 # exceptiondef-compileerror |
| ECMAScript® 2026 語言規範 # sec-native-error-types-used-in-this-standard |
瀏覽器相容性
載入中…