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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
URIError
URIError() constructor
URIError is serializable

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

関連情報