aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/webassembly/runtimeerror/index.md
blob: 9919812d760bd4c62e9d08aed33e858f391ab6d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: WebAssembly.RuntimeError
slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError
tags:
  - API
  - Class
  - JavaScript
  - Reference
  - RuntimeError
  - WebAssembly
browser-compat: javascript.builtins.WebAssembly.RuntimeError
translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError
---
{{JSRef}}

**`WebAssembly.RuntimeError`** オブジェクトは、 WebAssembly が[トラップ](https://webassembly.org/docs/semantics/#traps)を指定するたびに例外として発生するエラー型です。

## コンストラクター

- [`WebAssembly.RuntimeError()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError/RuntimeError)
  - : 新しい `WebAssembly.RuntimeError` オブジェクトを生成します。

## インスタンスプロパティ

- {{jsxref("Error.prototype.message", "WebAssembly.RuntimeError.prototype.message")}}
  - : エラーメッセージ。 {{jsxref("Error")}} から継承しています。
- {{jsxref("Error.prototype.name", "WebAssembly.RuntimeError.prototype.name")}}
  - : エラー名。 {{jsxref("Error")}} から継承しています。
- {{jsxref("Error.prototype.fileName", "WebAssembly.RuntimeError.prototype.fileName")}}
  - : このエラーを発生させたファイルのパス。 {{jsxref("Error")}} から継承しています。
- {{jsxref("Error.prototype.lineNumber", "WebAssembly.RuntimeError.prototype.lineNumber")}}
  - : このエラーを発生させたファイルの行番号。 {{jsxref("Error")}} から継承しています。
- {{jsxref("Error.prototype.columnNumber", "WebAssembly.RuntimeError.prototype.columnNumber")}}
  - : このエラーが発生した行の列番号。 {{jsxref("Error")}} から継承しています。
- {{jsxref("Error.prototype.stack", "WebAssembly.RuntimeError.prototype.stack")}}
  - : スタックトレース。 {{jsxref("Error")}} から継承しています。

## インスタンスメソッド

- {{jsxref("Error.prototype.toSource", "WebAssembly.RuntimeError.prototype.toSource()")}}
  - : 同じエラーを評価できるコードを返します。 {{jsxref("Error")}} から継承しています。
- {{jsxref("Error.prototype.toString", "WebAssembly.RuntimeError.prototype.toString()")}}
  - : 指定された `Error` オブジェクトを表す文字列を返します。{{jsxref("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);                               // コードが実行されていた位置を返す
}
```

## 仕様書

{{Specifications}}

## ブラウザーの互換性

{{Compat}}

## 関連情報

- [WebAssembly](/ja/docs/WebAssembly) 概要ページ
- [WebAssembly の概念](/ja/docs/WebAssembly/Concepts)
- [WebAssembly JavaScript API の使用](/ja/docs/WebAssembly/Using_the_JavaScript_API)