This translation is incomplete. この記事の翻訳にご協力ください
URIError オブジェクトは、グローバル URI 処理関数が誤った使い方をされたことを示すエラーです。
構文
new URIError([message[, fileName[, lineNumber]]])
引数
- message Optional
- 人間に読めるエラーの説明。
fileNameOptional- 例外を引き起こしたコードを含むファイル名。
lineNumberOptional- 例外を引き起こしたコードの行番号。
説明
URIError は、URI 処理関数が奇妙な形の URI を渡された場合に投げられます。
プロパティ
URIError.prototypeURIErrorオブジェクトにプロパティを追加することができます。
メソッド
グローバルな URIError オブジェクトは、自分自身のメソッドを持っていませんが、プロトタイプチェーンを通していくつかのメソッドを継承しています。
URIError インスタンス
プロパティ
URIError.prototype.constructor- Specifies the function that created an instance's prototype.
URIError.prototype.message- Error message. Although ECMA-262 specifies that
URIErrorshould provide its ownmessageproperty, in SpiderMonkey, it inheritsError.prototype.message. URIError.prototype.name- Error name. Inherited from
Error. URIError.prototype.fileName- Path to file that raised this error. Inherited from
Error. URIError.prototype.lineNumber- Line number in file that raised this error. Inherited from
Error. URIError.prototype.columnNumber- Column number in line that raised this error. Inherited from
Error. URIError.prototype.stack- Stack trace. Inherited from
Error.
例
URIError をキャッチ
try {
decodeURIComponent('%');
} catch (e) {
console.log(e instanceof URIError); // true
console.log(e.message); // "malformed URI sequence"
console.log(e.name); // "URIError"
console.log(e.fileName); // "Scratchpad/1"
console.log(e.lineNumber); // 2
console.log(e.columnNumber); // 2
console.log(e.stack); // "@Scratchpad/2:2:3\n"
}
URIError を生成
try {
throw new URIError('Hello', 'someFile.js', 10);
} catch (e) {
console.log(e instanceof URIError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "URIError"
console.log(e.fileName); // "someFile.js"
console.log(e.lineNumber); // 10
console.log(e.columnNumber); // 0
console.log(e.stack); // "@Scratchpad/2:2:9\n"
}
仕様
ブラウザ実装状況
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| デスクトップ | モバイル | サーバー | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
URIError | Chrome 完全対応 1 | Edge 完全対応 12 | Firefox 完全対応 1 | IE 完全対応 5.5 | Opera 完全対応 5 | Safari 完全対応 1 | WebView Android 完全対応 1 | Chrome Android 完全対応 18 | Firefox Android 完全対応 4 | Opera Android 完全対応 10.1 | Safari iOS 完全対応 1 | Samsung Internet Android 完全対応 1.0 | nodejs 完全対応 あり |
URIError() constructor | Chrome 完全対応 1 | Edge 完全対応 12 | Firefox 完全対応 1 | IE 完全対応 5.5 | Opera 完全対応 5 | Safari 完全対応 1 | WebView Android 完全対応 1 | Chrome Android 完全対応 18 | Firefox Android 完全対応 4 | Opera Android 完全対応 10.1 | Safari iOS 完全対応 1 | Samsung Internet Android 完全対応 1.0 | nodejs 完全対応 あり |
凡例
- 完全対応
- 完全対応