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