URIError
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
URIError オブジェクトは、グローバル URI 処理関数が間違った方法で使用された場合のエラーを表します。
コンストラクター
URIError()-
新しい
URIErrorオブジェクトを生成します。
インスタンスプロパティ
URIError.prototype.message-
エラーメッセージです。 ECMA-262 において
URIErrorは自身のmessageプロパティを提供するべきとされていますが、 SpiderMonkey ではError.prototype.messageを継承しています。 URIError.prototype.name-
エラー名です。
Errorから継承しています。 URIError.prototype.fileName-
このエラーが発生したファイルのパスです。
Errorから継承しています。 URIError.prototype.lineNumber-
このエラーが発生したファイル内の行番号です。
Errorから継承しています。 URIError.prototype.columnNumber-
このエラーが発生した行内の桁番号です。
Errorから継承しています。 URIError.prototype.stack-
スタックトレースです。
Errorから継承しています。
例
>URIError のキャッチ
js
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 の生成
js
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"
}
仕様書
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-native-error-types-used-in-this-standard-urierror> |
ブラウザーの互換性
Loading…