URIError - JavaScript 编辑
The URIError
object represents an error when a global URI handling function was used in a wrong way.
Constructor
URIError()
- Creates a new
URIError
object.
Instance properties
URIError.prototype.message
- Error message. Although ECMA-262 specifies that
URIError
should provide its ownmessage
property, in SpiderMonkey, it inheritsError.prototype.message
. URIError.prototype.name
- Error name. Inherited from
Error
. URIError.prototype.fileName
- Path to file that raised this error. Inherited from
Error
. URIError.prototype.lineNumber
- Line number in file that raised this error. Inherited from
Error
. URIError.prototype.columnNumber
- Column number in line that raised this error. Inherited from
Error
. URIError.prototype.stack
- Stack trace. Inherited from
Error
.
Examples
Catching an 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"
}
Creating an 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"
}
Specifications
Specification |
---|
ECMAScript (ECMA-262) The definition of 'URIError' in that specification. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论