From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/syntaxerror/index.html | 99 ++++++++++++++++++++++ .../syntaxerror/syntaxerror/index.html | 89 +++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/syntaxerror/index.html create mode 100644 files/ja/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.html (limited to 'files/ja/web/javascript/reference/global_objects/syntaxerror') diff --git a/files/ja/web/javascript/reference/global_objects/syntaxerror/index.html b/files/ja/web/javascript/reference/global_objects/syntaxerror/index.html new file mode 100644 index 0000000000..8180cbe7f5 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/syntaxerror/index.html @@ -0,0 +1,99 @@ +--- +title: SyntaxError +slug: Web/JavaScript/Reference/Global_Objects/SyntaxError +tags: + - Error + - JavaScript + - Object + - Reference + - SyntaxError +translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError +--- +
{{JSRef}}
+ +

SyntaxError オブジェクトは、構文的に不正なコードを解釈しようとした場合のエラーを表します。これは、 JavaScript エンジンが、コードを解析中に言語の構文に従わないトークンまたはトークンの順序に遭遇した場合に発生します。

+ +

コンストラクター

+ +
+
{{jsxref("Global_Objects/SyntaxError/SyntaxError", "SyntaxError()")}}
+
新しい SyntaxError オブジェクトを生成します。
+
+ +

インスタンスプロパティ

+ +
+
{{jsxref("Error.prototype.message", "SyntaxError.prototype.message")}}
+
エラーメッセージです。 ECMA-262 において {{jsxref("SyntaxError")}} は自身の message プロパティを提供するべきとされていますが、 SpiderMonkey では {{jsxref("Error.prototype.message")}} を継承しています。
+
{{jsxref("Error.prototype.name", "SyntaxError.prototype.name")}}
+
エラー名です。 {{jsxref("Error")}} から継承しています。
+
{{jsxref("Error.prototype.fileName", "SyntaxError.prototype.fileName")}}
+
このエラーが発生したファイルのパスです。 {{jsxref("Error")}} から継承しています。
+
{{jsxref("Error.prototype.lineNumber", "SyntaxError.prototype.lineNumber")}}
+
このエラーが発生したファイル内の行番号です。 {{jsxref("Error")}} から継承しています。
+
{{jsxref("Error.prototype.columnNumber", "SyntaxError.prototype.columnNumber")}}
+
このエラーが発生した行内の桁数です。 {{jsxref("Error")}} から継承しています。
+
{{jsxref("Error.prototype.stack", "SyntaxError.prototype.stack")}}
+
スタックトレースです。 {{jsxref("Error")}} から継承しています。
+
+ +

+ +

SyntaxError のキャッチ

+ +
try {
+  eval('hoo bar');
+} catch (e) {
+  console.error(e instanceof SyntaxError);
+  console.error(e.message);
+  console.error(e.name);
+  console.error(e.fileName);
+  console.error(e.lineNumber);
+  console.error(e.columnNumber);
+  console.error(e.stack);
+}
+
+ +

SyntaxError の生成

+ +
try {
+  throw new SyntaxError('Hello', 'someFile.js', 10);
+} catch (e) {
+  console.error(e instanceof SyntaxError); // true
+  console.error(e.message);                // Hello
+  console.error(e.name);                   // SyntaxError
+  console.error(e.fileName);               // someFile.js
+  console.error(e.lineNumber);             // 10
+  console.error(e.columnNumber);           // 0
+  console.error(e.stack);                  // @debugger eval code:3:9
+}
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-syntaxerror', 'SyntaxError')}}
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("javascript.builtins.SyntaxError")}}

+
+ +

関連情報

+ + diff --git a/files/ja/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.html b/files/ja/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.html new file mode 100644 index 0000000000..03782dc244 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/syntaxerror/syntaxerror/index.html @@ -0,0 +1,89 @@ +--- +title: SyntaxError() コンストラクター +slug: Web/JavaScript/Reference/Global_Objects/SyntaxError/SyntaxError +tags: + - Constructor + - JavaScript + - Reference + - SyntaxError +translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError/SyntaxError +--- +
{{JSRef}}
+ +

SyntaxError オブジェクトは、文法的に無効なコードを解釈しようとしたときのエラーを表します。

+ +

構文

+ +
new SyntaxError([message[, fileName[, lineNumber]]])
+ +

引数

+ +
+
message {{optional_inline}}
+
人間が読むためのエラーの説明です。
+
fileName {{optional_inline}}
+
例外が発生したコードを含むファイルの名前です。
+
lineNumber {{optional_inline}}
+
例外が発生したコードの行番号です。
+
+ +

+ +

SyntaxError の捕捉

+ +
try {
+  eval('hoo bar');
+} catch (e) {
+  console.error(e instanceof SyntaxError);
+  console.error(e.message);
+  console.error(e.name);
+  console.error(e.fileName);
+  console.error(e.lineNumber);
+  console.error(e.columnNumber);
+  console.error(e.stack);
+}
+
+ +

SyntaxError の生成

+ +
try {
+  throw new SyntaxError('Hello', 'someFile.js', 10);
+} catch (e) {
+  console.error(e instanceof SyntaxError); // true
+  console.error(e.message);                // Hello
+  console.error(e.name);                   // SyntaxError
+  console.error(e.fileName);               // someFile.js
+  console.error(e.lineNumber);             // 10
+  console.error(e.columnNumber);           // 0
+  console.error(e.stack);                  // @debugger eval code:3:9
+}
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ESDraft', '#sec-nativeerror-constructors', 'NativeError constructor')}}
+ +

ブラウザーの互換性

+ +
+ + +

{{Compat("javascript.builtins.SyntaxError.SyntaxError")}}

+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf