Summary
Components.Exception
is a JavaScript constructor to create nsIXPCException objects. These exception objects may be thrown when implementing xpcom interfaces in JavaScript, and they can provide better diagnostics in the error console if not caught than simply throwing an nsresult
's value will.
See also nsIXPCException
.
Syntax
var exception = [ new ] Components.Exception([ message [, result [, stack [, data ] ] ] ]);
Parameters
message
- a string which can be displayed in the error console when your exception is thrown or in other developer-facing locations, defaulting to 'exception'
result
- the
nsresult
value of the exception, which defaults toComponents.results.NS_ERROR_FAILURE
stack
- an XPCOM stack to be set on the exception (defaulting to the current stack chain)
data
- any additional data you might want to store, defaulting to
null
Example
throw Components.Exception("I am throwing an Exception from a Javascript XPCOM component.");