URIError
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* 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® 2025 Language Specification # sec-native-error-types-used-in-this-standard-urierror |
ブラウザーの互換性
BCD tables only load in the browser