Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

URIError

BaselineWidely available *

TheURIError object represents an error when a global URI handling function was used in a wrong way.

URIError is aserializable object, so it can be cloned withstructuredClone() or copied betweenWorkers usingpostMessage().

URIError is a subclass ofError.

Constructor

URIError()

Creates a newURIError object.

Instance properties

Also inherits instance properties from its parentError.

These properties are defined onURIError.prototype and shared by allURIError instances.

URIError.prototype.constructor

The constructor function that created the instance object. ForURIError instances, the initial value is theURIError constructor.

URIError.prototype.name

Represents the name for the type of error. ForURIError.prototype.name, the initial value is"URIError".

Instance methods

Inherits instance methods from its parentError.

Examples

Catching an 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.stack); // Stack of the error}

Creating an URIError

js
try {  throw new URIError("Hello");} catch (e) {  console.log(e instanceof URIError); // true  console.log(e.message); // "Hello"  console.log(e.name); // "URIError"  console.log(e.stack); // Stack of the error}

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-native-error-types-used-in-this-standard-urierror

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp