URIError

翻譯不完整。 請幫助我們翻譯這篇文章!

URIError 物件在全域的URI處理函式被錯誤使用時作為一個錯誤被拋出。

語法

new URIError([message[, fileName[, lineNumber]]])

參數

message
可選。具人類可讀性的錯誤說明
fileName
可選。包含造成錯誤發生的程式碼的檔案名稱
lineNumber
可選。造成錯誤發生的程式碼行號

說明

URIError 在全域的URI處理函式被傳入了一個錯誤編碼的URI時被拋出。

屬性

URIError.prototype
允許對一個 URIError 物件增加其屬性。

方法

普遍的 URIError 自身沒有包含方法,儘管他的確從原型鍊中繼承了一些。

URIError 物件實體

屬性

URIError.prototype
Allows the addition of properties to a URIError object.

方法

The global URIError contains no methods of its own. However, it does inherit some methods through the prototype chain.

範例

Catch 一個 URIError

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

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"
}

規範

規範 狀態
ECMAScript 3rd Edition (ECMA-262)
The definition of 'URIError' in that specification.
Standard Initial definition
ECMAScript 5.1 (ECMA-262)
The definition of 'URIError' in that specification.
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'URIError' in that specification.
Standard  
ECMAScript (ECMA-262)
The definition of 'URIError' in that specification.
Living Standard  

瀏覽器相容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
URIErrorChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 5Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support Yes
URIError() constructorChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 5Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support Yes

Legend

Full support  
Full support

另見