WebAssembly.CompileError() コンストラクター

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.

WebAssembly.CompileError() コンストラクターは、新しい WebAssembly の CompileError オブジェクトを生成します。これは WebAssembly のデコードまたは検証中のエラーを示します。

構文

js
new WebAssembly.CompileError();
new WebAssembly.CompileError(message);
new WebAssembly.CompileError(message, fileName);
new WebAssembly.CompileError(message, fileName, lineNumber);

引数

message 省略可

このエラーの人間が読める説明です。

fileName 省略可

例外が発生したコードを含むファイル名です。

lineNumber 省略可

例外が発生したコードの行番号です。

新しい 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); // コードの実行されていた位置を返す
}

仕様書

Specification
WebAssembly JavaScript Interface
# exceptiondef-compileerror
ECMAScript® 2025 Language Specification
# sec-nativeerror-constructors

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
CompileError() constructor

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報