Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Components.Exception

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 to Components.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.");

Document Tags and Contributors

 Contributors to this page: teoli, trevorh, Varmaa, Mgjbot, Waldo, sdwilsh, Nickolay
 Last updated by: trevorh,