[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/URIError/URIError [Back]  [Original]

URIError() constructor - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

URIError() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

URIError() URI .

In this article

js
new URIError();
new URIError(message);
new URIError(message, fileName);
new URIError(message, fileName, lineNumber);

message Optional

.

fileName Optional

.

lineNumber Optional

.

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 2027 LanguageSpecification
# sec-nativeerror-constructors


Web Proxy Viewer  |  New URL  |  Original Page