Search completed in 0.97 seconds.
234 results for "NS_ERROR":
Your results are loading. Please wait...
NS_ERROR
this macro is meant for critical errors; like assertions, ns_errors should not be reachable.
... syntax ns_error("error text"); ...
Error codes returned by Mozilla APIs
for example, by using components.results.ns_error_not_initialized general errors the following errors are general and can occur when using any component.
... ns_error_not_initialized (0xc1f30001) an attempt was made to use a component or object which has not yet been initialized.
... ns_error_already_initialized (0xc1f30002) an attempt is made to initialize a component or object again which has already been initialized.
...And 68 more matches
nsIFile
exceptions thrown ns_error_file_not_directory indicates that this nsifile does not reference a directory.
... exceptions thrown ns_error_file_invalid_path indicates that this nsifile does not reference a symbolic link.
... exceptions thrown ns_error_file_unrecognized_path indicates that anode incorrectly contains a path separator character.
...And 36 more matches
nsIHttpChannel
exceptions thrown ns_error_failure if set after the channel has been opened.
...if zero, the channel will fail to redirect and will generate a ns_error_redirect_loop failure status.
... exceptions thrown ns_error_in_progress if set after the channel has been opened.
...And 23 more matches
nsIZipWriter
attempting to perform a synchronous operation on the interface while the background queue is in progress will throw an ns_error_in_progress exception.
... exceptions thrown ns_error_not_initialized if no zip file has been opened.
... exceptions thrown ns_error_not_initialized no zip file is open.
...And 23 more matches
nsIEffectiveTLDService
exceptions thrown ns_error_invalid_arg this exception is thrown if the hostname in auri is empty.
... ns_error_insufficient_domain_levels this exception is thrown if there were insufficient subdomain levels in the hostname to satisfy the requested aadditionalparts value.
... ns_error_host_is_ip_address this exception is thrown if auri is a numeric ipv4 or ipv6 address.
...And 11 more matches
Modularization techniques - Archive of obsolete content
const nsiid &aiid, void **aresult); ns_imethod_(void) lockfactory(prbool alock); }; /* * nssample implementation */ nssample::nssample() { mrefcnt = 0; } nssample::~nssample() { assert(mrefcnt == 0); } ns_imethod nssample::queryinterface(const nsiid &aiid, void **aresult) { if (aresult == null) { return ns_error_null_pointer; } // always null result, in case of failure *aresult = null; if (aiid.equals(kisupportsiid)) { *aresult = (void *) this; } else if (aiid.equals(kisampleiid)) { *aresult = (void *) this; } if (aresult != null) { return ns_error_no_interface; } addref(); return ns_ok; } nsrefcount nssample::addref() { return ++mrefcnt; } nsrefcount nssample::rel...
... } return mrefcnt; } /* * nssamplefactory implementation */ nssamplefactory::nssamplefactory() { mrefcnt = 0; } nssamplefactory::~nssamplefactory() { assert(mrefcnt == 0); } ns_imethodimp nssamplefactory::queryinterface(const nsiid &aiid, void **aresult) { if (aresult == null) { return ns_error_null_pointer; } // always null result, in case of failure *aresult = null; if (aiid.equals(kisupportsiid)) { *aresult = (void *) this; } else if (aiid.equals(kifactoryiid)) { *aresult = (void *) this; } if (*aresult == null) { return ns_error_no_interface; } addref(); // increase reference count for caller return ns_ok; } ns_imethodimp(nsrefcount) nssamplefact...
... } return mrefcnt; } ns_imethodimp nssamplefactory::createinstance(nsisupports *aouter, const nsiid &aiid, void **aresult) { if (aresult == null) { return ns_error_null_pointer; } *aresult = null; nsisupports inst = new nssample(); if (inst == null) { return ns_error_out_of_memory; } nsresult res = inst->queryinterface(aiid, aresult); if (res != ns_ok) { // we didn't get the right interface, so clean up delete inst; } return res; } void nssamplefactory::lockfactory(prbool alock) { // not implemented in simplest case.
...And 7 more matches
Space Manager Detailed Design - Archive of obsolete content
the coordinate is * relative to the upper-left corner of the local coordinate space * @param amaxsize the size to use to constrain the band data * @param abanddata [in,out] used to return the list of trapezoids that * describe the available space and the unavailable space * @return ns_ok if successful and ns_error_failure if the band data is not * not large enough.
...must not be null * @param aunavailablespace the bounding rect of the unavailable space * @return ns_ok if successful * ns_error_failure if there is already a region tagged with aframe */ nsresult addrectregion(nsiframe* aframe, const nsrect& aunavailablespace); /** * resize the rectangular region associated with aframe by the specified * deltas.
...you specify whether the width change applies to the left or right edge * * returns ns_ok if successful, ns_error_invalid_arg if there is no region * tagged with aframe */ enum affectededge {leftedge, rightedge}; nsresult resizerectregion(nsiframe* aframe, nscoord adeltawidth, nscoord adeltaheight, affectededge aedge = rightedge); /** * offset the region associated with aframe by the specified amount.
...And 7 more matches
An Overview of XPCOM
implementation of nsisupports interface // initialize the reference count to 0 sample::sample() : mrefcnt(0) { } sample::~sample() { } // typical, generic implementation of qi ns_imethodimp sample::queryinterface(const nsiid &aiid, void **aresult) { if (!aresult) { return ns_error_null_pointer; } *aresult = null; if (aiid.equals(kisupportsiid)) { *aresult = (void *) this; } if (!*aresult) { return ns_error_no_interface; } // add a reference addref(); return ns_ok; } ns_imethodimp_(nsrefcnt) sample::addref() { return ++mrefcnt; } ns_imethodimp_(nsrefcnt) sample::release() { if (--mrefcnt == 0) { delete this; return 0; } // optiona...
... common xpcom error codes ns_error_not_initialized returned when an instance is not initialized.
... ns_error_already_initialized returned when an instance is already initialized.
...And 7 more matches
mozIStorageService
if this method throws ns_error_file_corrupted, it's recommended that you call mozistorageservice.backupdatabasefile() to back up the database so that user data is not lost (although we have no way of recovering this data yet).
...if you use this method to open a database containing virtual tables, it will think the database is corrupted and throw ns_error_file_corrupted.
...exceptions thrown ns_error_failure an error occurred attempting to open the database.
...And 7 more matches
Starting WebLock
* ns_error_failure if there are no more elements * to enumerate.
... xpidl code generation the xpidl compiler also generates a stub implementation of the interface in a commented section of the generated header file, in which each method returns ns_error_not_implemented.
... * * @return ns_error_failure if a property with that * name doesn't exist.
...And 6 more matches
nsICrashReporter
exceptions thrown ns_error_not_initialized if crash reporting is not initialized.
... exceptions thrown ns_error_failure on get if no url is set.
... ns_error_invalid_arg on set if a non-http(s) url is assigned.
...And 5 more matches
Creating the Component Code
ns_imethodimp samplefactory::createinstance(nsisupports *aouter, const nsiid & iid, void * *result) { if (!result) return ns_error_invalid_arg; sample* sample = new sample(); if (!sample) return ns_error_out_of_memory; nsresult rv = sample->queryinterface(iid, result); if (ns_failed(rv)) { *result = nsnull; delete sample; } return rv; } weblock1.cpp before any of the improvements and xpcom tools we describe in the following chapter are brought in, the source code for the weblock component that ...
...efcnt; public: sample(); virtual ~sample(); ns_imethod queryinterface(const nsiid &aiid, void **aresult); ns_imethod_(nsrefcnt) addref(void); ns_imethod_(nsrefcnt) release(void); }; sample::sample() { mrefcnt = 0; } sample::~sample() { } ns_imethodimp sample::queryinterface(const nsiid &aiid, void **aresult) { if (aresult == null) { return ns_error_null_pointer; } *aresult = null; if (aiid.equals(kisupportsiid)) { *aresult = (void *) this; } if (*aresult == null) { return ns_error_no_interface; } addref(); return ns_ok; } ns_imethodimp_(nsrefcnt) sample::addref() { return ++mrefcnt; } ns_imethodimp_(nsrefcnt) sample::release() { if (--mrefcnt == 0) { delete this; return 0; } return mrefcnt; } // ...
...ethod_(nsrefcnt) release(void); ns_imethod createinstance(nsisupports *aouter, const nsiid & iid, void * *result); ns_imethod lockfactory(prbool lock); }; samplefactory::samplefactory() { mrefcnt = 0; } samplefactory::~samplefactory() { } ns_imethodimp samplefactory::queryinterface(const nsiid &aiid, void **aresult) { if (aresult == null) { return ns_error_null_pointer; } *aresult = null; if (aiid.equals(kisupportsiid)) { *aresult = (void *) this; } else if (aiid.equals(kifactoryiid)) { *aresult = (void *) this; } if (*aresult == null) { return ns_error_no_interface; } addref(); return ns_ok; } ns_imethodimp_(nsrefcnt) samplefactory::addref() { return ++mrefcnt; } ns_imethodimp_(nsrefcnt) samplefactory::release(...
...And 4 more matches
nsIAccessibleEditableText
exceptions thrown ns_error_failure indicates the text cannot be copied into the clipboard.
... exceptions thrown ns_error_failure indicates the text cannot be deleted or copied into the clipboard.
... exceptions thrown ns_error_failure indicates the text cannot be deleted.
...And 4 more matches
nsIContentPrefService
exceptions thrown ns_error_illegal_value if agroup is not a string, nsiuri, or null.
...exceptions thrown ns_error_illegal_value if agroup is not a string, nsiuri, or null.
...exceptions thrown ns_error_illegal_value if aname is null or an empty string.
...And 4 more matches
nsIControllers
exceptions thrown ns_error_out_of_memory getcontrollerat() returns the controller instance at the given position.
...exceptions thrown ns_error_failure the given index is out of range.
...exceptions thrown ns_error_failure the id is greater than the number of controllers that have been inserted, or the controller has since been removed.
...And 4 more matches
nsIDownloadManager
exceptions thrown ns_error_failure the download is not in progress.
... exceptions thrown ns_error_not_available the download is not in the database.
... exceptions thrown ns_error_failure the download is not in progress.
...And 4 more matches
nsILivemarkService
exceptions thrown ns_error_invalid_arg if the folder id isn't known or identifies a folder that isn't a livemark container.
... ns_error_malformed_uri if the site uri annotation has somehow been corrupted (and can't be turned into an nsiuri) getlivemarkidforfeeduri() determines whether the feed uri is a currently registered livemark.
... exceptions thrown ns_error_invalid_arg if the folder id isn't known or identifies a folder that isn't a livemark container.
...And 4 more matches
nsIToolkitProfileService
this may throw an ns_error_failure (0x80004005) when trying to get the current profile if it's unavailable or if permissions restrict access.
...exceptions thrown ns_error_unexpected an unexpected error condition occurred.
... ns_error_file_not_directory one of the specified directory files is not actually a directory.
...And 4 more matches
nsIURI
exceptions thrown ns_error_failure if host is not applicable to the uri scheme (e.g.
... exceptions thrown ns_error_failure if hostport is not applicable to the uri scheme (e.g.
... exceptions thrown ns_error_failure if password is not applicable to the uri scheme (e.g.
...And 4 more matches
Index
MozillaTechXPCOMIndex
success xpcom, xpcom_macros macro 142 ns ensure true xpcom, xpcom_macros macro 143 ns_abort_if_false this was removed in bug 1127201 144 ns_addref xpcom, xpcom_macros macro 145 ns_assertion xpcom, xpcom_macros macro 146 ns_ensure_arg_pointer xpcom, xpcom_macros macro 147 ns_error xpcom, xpcom_macros throws a assertion (ns_assertion) with the text "error: (error text)", so writes this text to console (stderr) and to debug logs (nspr logging).
... this macro is meant for critical errors; like assertions, ns_errors should not be reachable.
...attempting to alter this bit will result in an ns_error_illegal_value.
...And 3 more matches
nsIAccessNode
ng propertyname); domstring getcomputedstylevalue(in domstring pseudoelt, in domstring propertyname); void scrollto(in unsigned long ascrolltype); void scrolltopoint(in unsigned long acoordinatetype, in long ax, in long ay); attributes note: attempting to access the attributes of a node that is unattached from the accessible tree will result in an exception - ns_error_failure.
... exceptions thrown ns_error_failure indicates that the access node is unattached from the accessible tree.
... exceptions thrown ns_error_failure indicates that the access node is unattached from the accessible tree.
...And 3 more matches
nsICryptoHash
exceptions thrown ns_error_not_initialized indicates that init() or initwithstring() has not been called.
... exceptions thrown ns_error_invalid_arg indicates that an unsupported algorithm type was passed initwithstring() initialize the hashing object.
... exceptions thrown ns_error_invalid_arg indicates that an unsupported algorithm type was passed update() adds an array of data to be hashed to the object.
...And 3 more matches
nsIHttpServer
* * @param port * the port upon which listening should happen, or -1 if no specific port is * desired * @throws ns_error_already_initialized * if this server is already started * @throws ns_error_not_available * if the server is not started and cannot be started on the desired port * (perhaps because the port is already in use or because the process does * not have privileges to do so) * @note * behavior is undefined if this method is called after stop() has been * called on this...
... * * @param callback * an asynchronous callback used to notify the user when this server is * stopped and all pending requests have been fully served * @throws ns_error_null_pointer * if callback is null * @throws ns_error_unexpected * if this server is not running */ void stop(in nsihttpserverstoppedcallback callback); /** * associates the local file represented by the string file with all requests * which match request.
...sually be canonicalized, since most browsers will do so * before sending otherwise-matching requests * @param handler * an object which will handle any requests for the given path, or null to * remove any existing handler; if while the server is running the handler * throws an exception while responding to a request, an http 500 response * will be returned * @throws ns_error_invalid_arg * if path does not begin with a "/" */ void registerpathhandler(in string path, in nsihttprequesthandler handler); /** * registers a custom prefix handler.
...And 3 more matches
nsILocalFile
exceptions thrown ns_error_file_unrecognized_path indicates that relativefilepath incorrectly begins with a path separator character or otherwise contains invalid characters.
... exceptions thrown ns_error_file_unrecognized_path indicates that relativefilepath incorrectly begins with a path separator character or otherwise contains invalid characters.
... exceptions thrown ns_error_file_unrecognized_path indicates that filepath is not an absolute file path or that it contains characters that are invalid for the filesystem.
...And 3 more matches
Using Dependent Libraries In Extension Components - Archive of obsolete content
// assume that we're in <extensiondir>/components, and we want to find // <extensiondir>/libraries nscomptr<nsifile> libraries; rv = alocation->getparent(getter_addrefs(libraries)); if (ns_failed(rv)) return rv; nscomptr<nsilocalfile> library(do_queryinterface(libraries)); if (!library) return ns_error_unexpected; library->setnativeleafname(ns_literal_cstring("libraries")); library->appendnative(ns_literal_cstring("dummy")); // loop through and load dependent libraries for (char const *const *dependent = kdependentlibraries; *dependent; ++dependent) { library->setnativeleafname(nsdependentcstring(*dependent)); prlibrary *lib; library->load(&lib); // 1) we...
... } library->setnativeleafname(ns_literal_cstring(krealcomponent)); prlibrary *lib; rv = library->load(&lib); if (ns_failed(rv)) return rv; nsgetmoduleproc getmoduleproc = (nsgetmoduleproc) pr_findfunctionsymbol(lib, ns_get_module_symbol); if (!getmoduleproc) return ns_error_failure; return getmoduleproc(acompmgr, alocation, aresult); } extensions/stub/bdsstubloader.cpp (for mac os x) the code as written above won't work for mac os x.
... // assume that we're in <extensiondir>/components, and we want to find // <extensiondir>/libraries nscomptr<nsifile> libraries; rv = alocation->getparent(getter_addrefs(libraries)); if (ns_failed(rv)) return rv; nscomptr<nsilocalfile> library(do_queryinterface(libraries)); if (!library) return ns_error_unexpected; library->setnativeleafname(ns_literal_cstring("libraries")); library->appendnative(ns_literal_cstring("dummy")); nscstring path; // loop through and load dependent libraries for (char const *const *dependent = kdependentlibraries; *dependent; ++dependent) { library->setnativeleafname(nsdependentcstring(*dependent)); rv = library->getnativepath(path); if (ns_fa...
...And 2 more matches
NetUtil.jsm
exceptions thrown this method throws an exception with the message "must have a non-null string spec or nsifile object" and result code ns_error_invalid_arg if aspec is null.
...if you don't specify a replacement character, any invalid sequences will result in ns_error_illegal_input being thrown.
... exceptions thrown ns_error_invalid_arg the specified stream is not an nsiinputstream.
...And 2 more matches
nsIAccessibleHyperLink
note: renamed from anchors in gecko 1.9 exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
...And 2 more matches
nsICryptoHMAC
exceptions thrown ns_error_not_initialized if init() has not been called.
...to create the key object use for instance: var keyobject = components.classes["@mozilla.org/security/keyobjectfactory;1"] .getservice(components.interfaces.nsikeyobjectfactory) .keyfromstring(components.interfaces.nsikeyobject.hmac, rawkeydata); exceptions thrown ns_error_invalid_arg if an unsupported algorithm type is passed.
... exceptions thrown ns_error_not_initialized if init() has not been called.
...And 2 more matches
nsIFaviconService
exceptions thrown ns_error_not_available thrown when we have never heard of this favicon url.
...exceptions thrown ns_error_not_available thrown when we have never heard of this favicon url.
...exceptions thrown ns_error_not_available when the page is not found or it has no favicon.
...And 2 more matches
nsIJumpListBuilder
exceptions thrown ns_error_not_available on all calls if taskbar functionality is not supported by the operating system.
...exceptions thrown ns_error_unexpected on internal errors.
... ns_error_illegal_value if an item is added that was removed since the last commit.
...And 2 more matches
nsINavHistoryContainerResultNode
ethod overview nsinavhistoryresultnode findnodebydetails(in autf8string auristring, in prtime atime, in long long aitemid, in boolean arecursive); nsinavhistoryresultnode getchild(in unsigned long aindex); unsigned long getchildindex(in nsinavhistoryresultnode anode); attributes attribute type description childcount unsigned long the number of child nodes; accessing this throws an ns_error_not_available exception of containeropen is false.
...exceptions thrown ns_error_not_available the container is not open.
...exceptions thrown ns_error_not_available the containeropen attribute is currently false, indicating that the node isn't open for access.
...And 2 more matches
nsIScriptableIO
exceptions thrown ns_error_invalid_arg alocation was null.
...exceptions thrown ns_error_invalid_arg afilepath was null.
...exceptions thrown ns_error_invalid_arg auri was null.
...And 2 more matches
nsIXULTemplateQueryProcessor
only fatal errors should be thrown, or ns_error_unexpected if generateresults() has already been called.
... exceptions thrown ns_error_unexpected if generateresults() has already been called.
...exceptions thrown ns_error_invalid_arg if aquery is invalid.
...And 2 more matches
nsIAbCard/Thunderbird3
exceptions thrown ns_error_not_available<tt> if the named property does not exist.
... <tt>ns_error_cannot_convert_data if the property cannot be converted to the desired type.
... exceptions thrown ns_error_not_available<tt> if the named property does not exist.
...And 2 more matches
platform/xpcom - Archive of obsolete content
if the factory or service is already registered, this function throws components.results.ns_error_factory_exists.
...if the factory or service isn't registered, this function throws components.results.ns_error_factory_not_registered.
... if it finds a match, it returns this, otherwise it throws components.results.ns_error_no_interface.
... parameters outer : null this argument must be null, or the function throws cr.ns_error_no_aggregation.
How to implement a custom autocomplete search component
*/ removevalueat: function(index, removefromdb) { this._results.splice(index, 1); this._comments.splice(index, 1); }, queryinterface: function(aiid) { if (!aiid.equals(ci.nsiautocompleteresult) && !aiid.equals(ci.nsisupports)) throw components.results.ns_error_no_interface; return this; } }; // implements nsiautocompletesearch function simpleautocompletesearch() { } simpleautocompletesearch.prototype = { /* * search for a given string and notify a listener (either synchronously * or asynchronously) of the result * * @param searchstring - the string to search for * @param searchparam - an extra parameter * @param previousres...
...mpleteresult(searchstring, ci.nsiautocompleteresult.result_success, 0, "", results, comments); listener.onsearchresult(this, newresult); } }, /* * stop an asynchronous search that is in progress */ stopsearch: function() { }, queryinterface: function(aiid) { if (!aiid.equals(ci.nsiautocompletesearch) && !aiid.equals(ci.nsisupports)) throw components.results.ns_error_no_interface; return this; } }; // factory var simpleautocompletesearchfactory = { singleton: null, createinstance: function (aouter, aiid) { if (aouter != null) throw components.results.ns_error_no_aggregation; if (this.singleton == null) this.singleton = new simpleautocompletesearch(); return this.singleton.queryinterface(aiid); } }; // module var simpleaut...
...me, contract_id, afilespec, alocation, atype); }, unregisterself: function(acompmgr, alocation, atype) { acompmgr = acompmgr.queryinterface(components.interfaces.nsicomponentregistrar); acompmgr.unregisterfactorylocation(class_id, alocation); }, getclassobject: function(acompmgr, acid, aiid) { if (!aiid.equals(components.interfaces.nsifactory)) throw components.results.ns_error_not_implemented; if (acid.equals(class_id)) return simpleautocompletesearchfactory; throw components.results.ns_error_no_interface; }, canunload: function(acompmgr) { return true; } }; // module initialization function nsgetmodule(acompmgr, afilespec) { return simpleautocompletesearchmodule; } starting in gecko 2.0, component registration has been changed, so you need t...
...o make the following changes: add an nsgetfactory() function: function nsgetfactory(cid) { if (cid.tostring().touppercase() != class_id.tostring().touppercase()) { throw components.results.ns_error_factory_not_registered; } return simpleautocompletesearchfactory; } you need to explicitly register the component by adding these lines into your chrome.manifest file: component {6224daa1-71x2-4d1a-ad90-01ca1c08e323} components/.js contract @mozilla.org/autocomplete/search;1?name=simple-autocomplete {6224daa1-71x2-4d1a-ad90-01ca1c08e323} you need to add the following method: getlabelat: function(index) { return this._results[index]; } to simpleautocompleteresult use this newly available component in a xul file like ...
Extending a Protocol
now let's implement the method in ./dom/base/navigator.cpp - we add a little bit of error boilerplate stuff, as is customary: already_addrefed<promise> navigator::echo(const nsastring& astring, errorresult& arv) { if (!mwindow || !mwindow->getdocshell()) { arv.throw(ns_error_unexpected); return nullptr; } refptr<promise> echopromise = promise::create(mwindow->asglobal(), arv); if (ns_warn_if(arv.failed())) { return nullptr; } // message passing magic will happen here!
... echochild* navigator::getechochild(errorresult& arv) { if (!mechochild) { if (!mwindow) { arv.throw(ns_error_unexpected); return nullptr; } auto windowglobalchild = mwindow->getwindowglobalchild(); // let's get us a child!
...we can now finally finish off ::echo(): already_addrefed<promise> navigator::echo(const nsastring& astring, errorresult& arv) { if (!mwindow || !mwindow->getdocshell()) { arv.throw(ns_error_unexpected); return nullptr; } refptr<promise> echopromise = promise::create(mwindow->asglobal(), arv); if (ns_warn_if(arv.failed())) { return nullptr; } errorresult rv; auto echochild = getechochild(rv); puts("[navigator.cpp] sending echo!"); // let's send astring to the parent!
... puts("[navigator.cpp] yay, we got a message back!"); // send the string back out a utf16 echopromise->mayberesolve(ns_convertutf8toutf16(returnedstring)); }, // reject lambda [echopromise](mozilla::ipc::responserejectreason&& areason) { puts("[navigator.cpp] boo, something went wrong!"); echopromise->maybereject(ns_error_unexpected); }); return echopromise.forget(); } now, ./mach build; ./mach run.
Mozilla DOM Hacking Guide
nscomptr<nsidomwindow> window(do_queryinterface(native)); ns_ensure_true(window, ns_error_unexpected); nscomptr<nsidomlocation> location; rv = window->getlocation(getter_addrefs(location)); ns_ensure_success(rv, rv); // use the dom to get the location object of the window object.
... ns_ensure_success(rv, rv); if (!::js_defineucproperty(cx, obj, ::js_getstringchars(str), ::js_getstringlength(str), v, nsnull, nsnull, 0)) { return ns_error_failure; } // this js api call defines the "location" property on the window object, its // value being the xpconnect wrapper for the location object.
...the second step is to map .location to .location.href in nswindowsh::setproperty() if (str == slocation_id) { // setting the location property jsstring *val = ::js_valuetostring(cx, *vp); ns_ensure_true(val, ns_error_unexpected); // convert the value assigned to location (i.e.
... nscomptr<nsidomwindow> window(do_queryinterface(native)); ns_ensure_true(window, ns_error_unexpected); // queryinterface to have a nsidomwindow pointer to call // getlocation() on it.
mozIStorageConnection
exceptions thrown ns_error_unexpected thrown if the method was called on a thread other than the one that opened the connection.
... exceptions thrown ns_error_unexpected the connection is to a memory database.
... exceptions thrown ns_error_unexpected thrown if any statement has been executed asynchronously on the connection, or if the method was called on a thread other than the one that opened the connection.
... exceptions thrown ns_error_failure table already exists or the requested table couldn't be created.
nsIAccessibleHyperText
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... ns_error_invalid_arg the link index is invalid.
... exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... return value missing description exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
nsIArray
exceptions thrown ns_error_failure if the array is empty (to make it easy to detect errors).
... ns_error_out_of_memory if there is not enough memory to complete the operation.
...exceptions thrown ns_error_failure if the element was not in the array.
... exceptions thrown ns_error_illegal_value when index > length-1.
nsIComponentManager
exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered.
... exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered.
... exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered.
... exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered.
nsIErrorService
error modules are obtained from nsresult code with ns_error_get_module.
...if no key is registered for the specified nsresult, then the caller should use the nsresult's code (obtained with ns_error_get_code) instead.
...should be one of the modules listed in xpcom/base/nserror.h, such as ns_error_module_storage.
...should be one of the modules listed in xpcom/base/nserror.h, such as ns_error_module_storage.
nsIHttpChannelInternal
this may throw an ns_error_not_available exception if accessed when the channel's endpoints haven't been determined yet, or any time the nsihttpactivityobserver.isactive attribute is false.
...this may throw an ns_error_not_available exception if accessed when the channel's endpoints haven't been determined yet, or any time the nsihttpactivityobserver.isactive attribute is false.
...this may throw an ns_error_not_available exception if accessed when the channel's endpoints haven't been determined yet, or any time the nsihttpactivityobserver.isactive attribute is false.
...this may throw an ns_error_not_available exception if accessed when the channel's endpoints haven't been determined yet, or any time the nsihttpactivityobserver.isactive attribute is false.
nsIMessageBroadcaster
throws ns_error_not_initialized if the sender is not initialized.
... for example, we will throw ns_error_not_initialized if we try to send a message to a cross-process frame but the other process has not yet been set up.
... throws ns_error_failure when the message receiver cannot be found.
... for example, we will throw ns_error_failure if we try to send a message to a cross-process frame whose process has crashed.
nsIMessageSender
throws ns_error_not_initialized if the sender is not initialized.
... for example, we will throw ns_error_not_initialized if we try to send a message to a cross-process frame but the other process has not yet been set up.
... throws ns_error_failure when the message receiver cannot be found.
... for example, we will throw ns_error_failure if we try to send a message to a cross-process frame whose process has crashed.
nsIMutableArray
any of these methods may throw ns_error_out_of_memory when the array must grow to complete the call, but the allocation fails.
... exceptions thrown ns_error_failure when a weak reference is requested, but the element does not support nsiweakreference.
... exceptions thrown ns_error_failure when a weak reference is requested, but the element does not support nsiweakreference.
... exceptions thrown ns_error_failure when a weak reference is requested, but the element does not support nsiweakreference.
nsIPrintingPrompt
if an embedder implemented service returns any error code (other than ns_error_abort) printing will terminate.
... to fly your own dialog you may: implement this service to display at least the print dialog and a print progress dialog or you may implement just one of the dialogs and pass back ns_error_not_implemented for any of the others.
... for the print dialog: you may stub out this service by having all the methods return ns_error_not_implemented.
...if an embedder implemented service returns ns_error_not_implemented for "showprintdialog" the toolkit will display the native print dialog.
nsIServiceManager
exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered.
... exceptions thrown ns_error_factory_not_registered indicates that the specified class is not registered.
... exceptions thrown ns_error_service_not_available indicates that the service hasn't been instantiated.
... exceptions thrown ns_error_service_not_available indicates that the service hasn't been instantiated.
nsISyncMessageSender
throws ns_error_not_initialized if the sender is not initialized.
... for example, we will throw ns_error_not_initialized if we try to send a message to a cross-process frame but the other process has not yet been set up.
... throws ns_error_failure when the message receiver cannot be found.
... for example, we will throw ns_error_failure if we try to send a message to a cross-process frame whose process has crashed.
nsIWebProgress
exceptions thrown ns_error_failure indicates that there is no associated dom window.
... exceptions thrown ns_error_invalid_arg indicates that alistener was either null or that it does not support weak references.
... ns_error_failure indicates that alistener was already registered.
... exceptions thrown ns_error_failure indicates that alistener was not registered.
nsIXULTemplateBuilder
errors throws ns_error_null_pointer if aresult or aquerynode is null.
...void removeresult( in nsixultemplateresult aresult ); parameters aresult the result to remove errors throws ns_error_null_pointer if aresult is null replaceresult() inform the template builder that one result should be replaced with another.
... errors throws ns_error_null_pointer if either argument is null, or ns_error_invalid_arg if the ids don't match resultbindingchanged() informs the template builder that one or more of the optional bindings for a result has changed.
...void resultbindingchanged( in nsixultemplateresult aresult ); parameters aresult the result to change errors throws ns_error_null_pointer if aresult is null getresultforid() returns the result for a given id.
Preferences - Archive of obsolete content
if there's a value of the wrong type and the preference is not locked, an ns_error_unexpected exception is thrown.
... otherwise an ns_error_unexpected exception is thrown.
...js_modules how to save preferences to save preferences into the default location: var prefservice = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice); prefservice.savepreffile(null); checking for existence of a key if you try to get the value of a nonexistent preference, an error will be thrown: error: ns_error_unexpected: component returned failure code: 0x8000ffff (ns_error_unexpected) [nsiprefbranch.getcharpref] to avoid such errors, you should check whether the key exists or not using nsiprefservice.getpreftype(), as shown below: var prefservicebranch = components.classes["@mozilla.org/preferences-service;1"] .getservice(components.interfaces.nsiprefservice).getbr...
XPCOM Objects - Archive of obsolete content
the only aspects to take into account are that methods and attributes must have the same names as their idl counterparts, and that the queryinterface method is implemented: queryinterface : function(aiid) { if (!aiid.equals(ci.xsihellocounter) && !aiid.equals(ci.nsisupports)) { throw cr.ns_error_no_interface; } return this; } the method is very simple, it validates that the caller is requesting a supported interface, otherwise it throws an exception.
...*/ _singletonobj: null, createinstance: function(aouter, aiid) { if (aouter != null) { throw cr.ns_error_no_aggregation; } // in this case we need a unique instance of the service.
... if (!this._singletonobj) { this._singletonobj = messagecounter; } return this._singletonobj.queryinterface(aiid); } }; if we wanted a class that can be instantiated, instead of a singleton service, the factory would look like this: var counterfactory = { createinstance: function(aouter, aiid) { if (aouter != null) { throw cr.ns_error_no_aggregation; } return (new counter()).queryinterface(aiid); } }; the instructions on how to build an idl file are included in the section setting up a development environment.
Implementing Download Resuming
the server is not using http 1.1), then accessing this attribute will throw an ns_error_not_resumable exception.
... detecting when a file changed if the file changed (that is, the entity id does not match), then necko will notify the stream listener with an ns_error_entity_changed error code.
...in such a case, the stream listener will get an ns_error_not_resumable status.
jsdIStackFrame
attempting to alter this bit will result in an ns_error_illegal_value.
...setting or getting this attribute on any other context will throw a ns_error_no_interface exception.
...once a jsdistackframe has been invalidated all method and property accesses will throw a ns_error_not_available exception.
nsIBidiKeyboard
note: this throws ns_error_not_implemented if the widget layer doesn't provide this information.
...exceptions thrown ns_error_failure if no right-to-left keyboards are installed.
... exceptions thrown ns_error_failure if no right-to-left keyboards are installed.
nsICachingChannel
exceptions thrown ns_error_not_available when there is not offline cache token.
...an error of ns_error_document_not_cached will be sent to the listener's onstoprequest if network io is necessary to complete the request.
...an error of ns_error_document_not_cached will be sent to the listener's onstoprequest in this case.
nsIDOMHTMLAudioElement
exceptions thrown ns_error_dom_invalid_state_err the stream has not been initialized for writing by a call to mozsetup().
... ns_error_dom_type_mismatch_err the data isn't a valid data type (an array or typed array of numeric values).
... ns_error_dom_index_size_err the number of samples specified doesn't divide evenly across the number of channels; you must provide exactly the same number of samples for all channels.
nsIFocusManager
setting this to null or to a non-top-level window throws an ns_error_invalid_arg exception.
...void clearfocus( in nsidomwindow awindow ); parameters awindow exceptions thrown ns_error_invalid_arg if awindow is null.
...exceptions thrown ns_error_invalid_arg if awindow is null.
nsIGlobalHistory3
implementors who wish to implement this interface but rely on nsiglobalhistory2.adduri() for redirect processing may throw ns_error_not_implemented from this method.
... if they do so, then callers must call nsiglobalhistory2.adduri() upon getting the ns_error_not_implemented result.
...not all histories have them; this need not be supported (just return ns_error_not_implemented.
nsIResumableChannel
exceptions thrown ns_error_not_resumable if this load is not resumable.
...during onstartrequest, this channel will have a status of ns_error_not_resumable if the file cannot be resumed, for example because the server doesn't support this.
...similarly, the status of this channel during onstartrequest may be ns_error_entity_changed, which indicates that the entity has changed, as indicated by a changed entityid.
nsIThread
exceptions thrown ns_error_unexpected shutdown() was erroneously called from within the thread itself, the thread was not created with the thread manager's nsithreadmanager.newthread() method, or the thread is already in the process of being shut down.
... exceptions thrown ns_error_unexpected the method was called when this thread wasn't the current thread.
... exceptions thrown ns_error_unexpected this method was called when this thread wasn't the current thread.
nsIXPConnect
returns: success: ns_ok failure: ns_error_xpc_bad_convert_js ns_error_failure.
... returns: success: ns_ok failure: ns_error_xpc_bad_convert_js ns_error_failure.
... returns: success: ns_ok failure: ns_error_xpc_bad_convert_native ns_error_xpc_cant_get_jsobject_of_dom_object ns_error_failure.
How to check the security state of an XMLHTTPRequest over SSL - Web APIs
ion createtcperrorfromfailedxhr(xhr) { let status = xhr.channel.queryinterface(ci.nsirequest).status; let errtype; if ((status & 0xff0000) === 0x5a0000) { // security module const nsinsserrorsservice = ci.nsinsserrorsservice; let nsserrorsservice = cc['@mozilla.org/nss_errors_service;1'].getservice(nsinsserrorsservice); let errorclass; // geterrorclass will throw a generic ns_error_failure if the error code is // somehow not in the set of covered errors.
...me = 'securityunsupportedtlsversionerror'; break; case 12: // ssl_error_bad_cert_domain, ssl(12) errname = 'securitycertificatedomainmismatcherror'; break; default: errname = 'securityerror'; break; } } } else { errtype = 'network'; switch (status) { // connect to host:port failed case 0x804b000c: // ns_error_connection_refused, network(13) errname = 'connectionrefusederror'; break; // network timeout error case 0x804b000e: // ns_error_net_timeout, network(14) errname = 'networktimeouterror'; break; // hostname lookup failed case 0x804b001e: // ns_error_unknown_host, network(30) errname = 'domainnotfounderror'; break; case 0...
...x804b0047: // ns_error_net_interrupt, network(71) errname = 'networkinterrupterror'; break; default: errname = 'networkerror'; break; } } // xxx we have no tcperror implementation right now because it's really hard to // do on b2g18.
Creating custom Firefox extensions with the Mozilla build system - Archive of obsolete content
otherwise the first module's xpt file will be overwritten by the second and you'll get ns_error_xpc_bad_iid errors when you try to access its idl interfaces from your code.
...the component implementation will include the methods for retrieving the path or file for the extension's home directory: mylocation.prototype = { queryinterface: function(iid) { if (iid.equals(nsisupports)) return this; if (iid.equals(myilocation)) return this; components.returncode = components.results.ns_error_no_interface; return null; }, get locationfile() { return __location__.parent.parent; } } this assumes that the component resides in a subdirectory of the extension directory (by convention, this directory is called components/).
MCD, Mission Control Desktop, AKA AutoConfig - Archive of obsolete content
"component returned failure code: 0xc1f30001 (ns_error_not_initialized) [nsildapurl.spec]" nsresult: "0xc1f30001 (ns_error_not_initialized)" location: "js frame :: file:////usr/lib/thunderbird-3.0b2/defaults/autoconfig/prefcalls.js :: getldapattributes :: line 174" data: no] bug 295329 had been re-opened .
..."could not convert javascript argument arg 0 [nsisupports.queryinterface]" nsresult: "0x80570009 (ns_error_xpc_bad_convert_js)" location: "js frame :: prefcalls.js :: getldapattributes :: line 177" data: no] autoconfig (pref) and ldap support in packages add ldap support in firefox 1.5 a least from firefox 1.5, autoconfig is compiled by default (cf.
Writing textual data - Archive of obsolete content
the last argument to init specifies that: 0x0000 means that writing unsupported characters throws an exception (with an error code of ns_error_loss_of_significant_data), and no data will be written.
... note: if the replacement character is not a supported character in the chosen character encoding, attempts to write unsupported characters will fail with ns_error_loss_of_significant_data.
CommandLine - Archive of obsolete content
0c9a66"); const class_name = "applicationnameclh"; const contract_id = "@example.com/applicationname/clh;1"; const cld_category = "m-applicationname"; var apphandler = { /* nsisupports */ queryinterface : function clh_qi(aiid) { if (aiid.equals(nsicommandlinehandler) || aiid.equals(nsifactory) || aiid.equals(nsisupports)) return this; throw components.results.ns_error_no_interface; }, /* nsicommandlinehandler */ handle : function clh_handle(acmdline) { var observerservice = components.classes["@mozilla.org/observer-service;1"] .getservice(components.interfaces.nsiobserverservice); observerservice.notifyobservers(acmdline, "commandline-args-changed", null); }, helpinfo : " -test <value> a test at...
...tribute\n", /* nsifactory */ createinstance : function mdh_ci(aouter, aiid) { if (aouter != null) { throw components.results.ns_error_no_aggregation; } return this.queryinterface(aiid); }, lockfactory : function mdh_lock(alock) { /* no-op */ } }; var apphandlermodule = { /* nsisupports */ queryinterface : function mod_qi(aiid) { if (aiid.equals(nsimodule) || aiid.equals(nsisupports)) return this; throw components.results.ns_error_no_interface; }, /* nsimodule */ getclassobject : function mod_gch(acompmgr, acid, aiid) { if (acid.equals(class_id)) return apphandler.queryinterface(aiid); throw components.results.ns_error_failure; }, registerself : function mod_regself(acompmgr, afilespec, alocation, atyp...
Using LDAP XPCOM with XULRunner - Archive of obsolete content
ent[] = moz_dll_prefix "mozldap" moz_dll_suffix; nsresult nsgetmodule(nsicomponentmanager* acompmgr, nsifile* alocation, nsimodule* *aresult) { nsresult rv; nscomptr<nsifile> libraries; rv = alocation->getparent(getter_addrefs(libraries)); if (ns_failed(rv)) return rv; nscomptr<nsilocalfile> library(do_queryinterface(libraries)); if (!library) return ns_error_unexpected; library->setnativeleafname(ns_literal_cstring("libraries")); library->appendnative(ns_literal_cstring("dummy")); // loop through and load dependent libraries for (char const *const *dependent = kdependentlibraries; *dependent; ++dependent) { library->setnativeleafname(nsdependentcstring(*dependent)); prlibrary *lib; library->load(&lib); // 1) we...
... } library->setnativeleafname(ns_literal_cstring(krealcomponent)); prlibrary *lib; rv = library->load(&lib); if (ns_failed(rv)) return rv; nsgetmoduleproc getmoduleproc = (nsgetmoduleproc) pr_findfunctionsymbol(lib, ns_get_module_symbol); if (!getmoduleproc) return ns_error_failure; return getmoduleproc(acompmgr, alocation, aresult); } then change your .mozconfig to add this line: ac_add_options --enable-extensions=ldapstub rebuild xulrunner.
Obsolete: XPCOM-based scripting for NPAPI plugins - Archive of obsolete content
ns_imethod getinterfaces(pruint32 *count, nsiid * **array) {return ns_error_not_implemented;} ns_imethod gethelperforlanguage(pruint32 language, nsisupports **_retval) {return ns_error_not_implemented;} ns_imethod getcontractid(char * *acontractid) {return ns_error_not_implemented;} ns_imethod getclassdescription(char * *aclassdescription) {return ns_error_not_implemented;} ns_imethod getclassid(nscid * *aclassid) {return ns_error_not_implemented;...
...} ns_imethod getclassidnoalloc(nscid *aclassidnoalloc) {return ns_error_not_implemented;} }; class nsscriptablepeer : public nsitestplugin, public nsclassinfomixin { public: nsscriptablepeer(); ~nsscriptablepeer(); ns_decl_isupports ns_decl_nsitestplugin }; nsscriptablepeer::nsscriptablepeer() { ns_init_isupports(); } nsscriptablepeer::~nsscriptablepeer() { } // notice that we expose our claim to implement nsiclassinfo.
Implementing QueryInterface
if ( !ainstanceptr ) return ns_error_null_pointer; nsisupports* foundinterface; if ( aiid.equals(nscomtypeinfo<nsix>::getiid()) ) foundinterface = ns_static_cast(nsix*, this); else if ( aiid.equals(nscomtypeinfo<nsiy>::getiid()) ) foundinterface = ns_static_cast(nsiy*, this); // ...as many cases as needed...
... */ { ns_assertion(ainstanceptr, "queryinterface requires a non-null destination!"); if ( !ainstanceptr ) return ns_error_null_pointer; nsisupports* foundinterface; if ( aiid.equals(nscomtypeinfo<nsix>::getiid()) ) foundinterface = ns_static_cast(nsix*, this); else if ( aiid.equals(nscomtypeinfo<nsiy>::getiid()) ) foundinterface = ns_static_cast(nsiy*, this); // note: don't check for |nsisupports|; |nsbaseimplementation| will do that for me.
Pork Tools
if (!*aresult) return ns_error_failure; return ns_ok; } nsifoo* getter() { nsifoo *result = null; // aresult below is kept for complicated cases // typically it wont be needed and can be removed nsifoo **aresult = &result; // *aresult patterns are replaced with result result = ...
...then nuke the declaration // nsresult rv; // move outparam to lhs var = getter(); // detect ns_ensure_success immediately following // and change it to an equivalent ns_ensure_true ns_ensure_true(var, ns_error_failure); // case 2 var = getter(); // case 3, eliminate rv2 decl given that it's not used elsewhere var = getter(); ns_ensure_true(var, ns_error_failure) } outparamdel also support rewriting getters such that they return already_addrefed<nsifoo>.
Places Developer Guide
}, queryinterface: function(iid) { if (iid.equals(ci.nsinavbookmarkobserver) || iid.equals(ci.nsisupports)) { return this; } throw cr.ns_error_no_interface; }, }; // register the observer with the bookmarks service var bmsvc = cc["@mozilla.org/browser/nav-bookmarks-service;1"] .getservice(ci.nsinavbookmarksservice); bmsvc.addobserver(observer, false); // un-register the observer when done.
...itle) { }, ondeleteuri: function(auri) { }, onclearhistory: function() { }, onpagechanged: function(auri, awhat, avalue) { }, onpageexpired: function(auri, avisittime, awholeentry) { }, queryinterface: function(iid) { if (iid.equals(components.interfaces.nsinavhistoryobserver) || iid.equals(components.interfaces.nsisupports)) { return this; } throw cr.ns_error_no_interface; } }; history.addobserver(observer, false); new tagging service the tagging of uris is provided by nsitaggingservice.
Using XPCOM Utilities to Make Things Easier
this is a common pattern when you have a local nscomptr in a function and you must pass back a reference to it, as in the following: someclass::get(nsisupports** aresult) { if (!aresult) return ns_error_null_pointer; nscomptr<nsisupports> value; object->method(getter_addrefs(value)); *aresult = value.get(); ns_if_addref(*aresult); return ns_ok; } the first thing that this method does is check to see that the caller passed a valid address.
...although we haven't formally introduced these two interfaces, the next code sample shows how simple it is to switch between these two interfaces: someclass::dosomething(nsifile* afile) { if (!afile) return ns_error_null_pointer; nsresult rv; nscomptr<nsilocalfile> localfile = do_queryinterface(afile, &rv); // ...
Mozilla internal string guide
ns_free(val); return ns_error_failure; } ...
...you can just use getter_copies() to wrap a string class argument, and the class will remember to free the buffer when it goes out of scope: { nsstring val; getvalue(getter_copies(val)); // val will free itself here if (somecondition) return ns_error_failure; ...
Components.results
if(something_unexpected_happened) throw components.results.ns_error_unexpected; the elements of the components.results object can be enumerated using a for-in loop.
...*/ queryinterface: function(id) { if (id.equals(ci.imyinterface)) return this; throw cr.ns_error_no_interface; } }; ...
mozIStorageAggregateFunction
tal / mnumbers.length(); nstarray<print64> data(mnumbers); for (pruint32 i = 0; i < data.length(); i++) { print32 value = data[i] - mean; data[i] = value * value; } total = 0; for (pruint32 i = 0; i < data.length(); i++) total += data[i]; nscomptr<nsiwritablevariant> result = do_createinstance("@mozilla.org/variant;1"); ns_ensure_true(result, ns_error_out_of_memory); rv = result->setasdouble(sqrt(double(total) / double(data.length()))); ns_ensure_success(rv, rv); ns_addref(*_result = result); return ns_ok; } private: nstarray<print32> mnumbers; }; // now, register our function with the database connection.
... nscomptr<mozistoragefunction> func = new standarddeviationfunc(); ns_ensure_true(func, ns_error_out_of_memory); nsresult rv = dbconn->createfunction( ns_literal_cstring("stddev"), 1, func ); ns_ensure_success(rv, rv); // run some query that uses the function.
mozIStorageFunction
class squarefunction : public mozistoragefunction { public: ns_imethod onfunctioncall(mozistoragevaluearray *aarguments, nsivariant **_result) { print32 value; nsresult rv = aarguments->getint32(&value); ns_ensure_success(rv, rv); nscomptr<nsiwritablevariant> result = do_createinstance("@mozilla.org/variant;1"); ns_ensure_true(result, ns_error_out_of_memory); rv = result->setasint64(value * value); ns_ensure_success(rv, rv); ns_addref(*_result = result); return ns_ok; } }; // now, register our function with the database connection.
... nscomptr<mozistoragefunction> func = new squarefunction(); ns_ensure_true(func, ns_error_out_of_memory); nsresult rv = dbconn->createfunction( ns_literal_cstring("square"), 1, func ); ns_ensure_success(rv, rv); // run some query that uses the function.
DoAction
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... ns_error_invalid_arg indicates that the given index is our of range.
GetActionDescription
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... ns_error_invalid_arg indicates that the given index is our of range.
nsIAccessibleImage
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
... exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
nsIAccessibleSelectable
exceptions thrown ns_error_failure if the specified object is not selectable.
... exceptions thrown ns_error_failure if the specified object is not selectable.
nsIApplicationCacheChannel
exceptions thrown ns_error_already_opened if set after calling asyncopen() on the channel.
...exceptions thrown ns_error_already_opened if set after calling asyncopen() on the channel.
nsIAuthModule
exceptions thrown ns_error_not_implemented if the underlying authentication mechanism does not support security layers.
... exceptions thrown ns_error_not_implemented if the underlying authentication mechanism does not support security layers.
nsIBinaryInputStream
exceptions thrown ns_error_failure if it can't read alength bytes.
... exceptions thrown ns_error_failure if it can't read alength bytes.
nsIBrowserSearchService
exceptions thrown ns_error_failure if the type is invalid, or if the description file cannot be successfully loaded.
... exceptions thrown ns_error_failure if newindex is out of bounds, or if engine is hidden.
nsICategoryManager
exceptions thrown ns_error_invalid_arg this error is returned if areplace is false and the category entry already has a value, or if apersist is true.
... exceptions thrown ns_error_not_available indicates that either the category or entry is undefined.
nsIChannel
exceptions thrown ns_error_already_opened if the channel is reopened ns_error_port_access_not_allowed if the specified port is in the nsioservice forbidden port list.
... exceptions thrown ns_error_in_progress if the channel is reopened.
nsICommandLine
exceptions thrown ns_error_invalid_arg the specified index is out of bounds.
...exceptions thrown ns_error_invalid_arg the specified flag has no value.
nsIDOMMozNetworkStatsManager
exceptions thrown ns_error_invalid_arg the filtering start date is greater than the end date.
... ns_error_not_implmented both appmanifesturl and servicetype are specified at the same time in the networkstatsgetoptions dictionary.
nsIDOMWindowUtils
exceptions thrown ns_error_not_available there is no current inner window displaydpi float the dpi of the display.
...throws ns_error_not_available if the count can't be provided.
nsIDictionary
if the key doesn't exist, ns_error_failure is returned.
...if the key doesn't exist, ns_error_failure will be returned.
nsIEventTarget
exceptions thrown ns_error_unexpected indicates that the thread is shutting down and has finished processing events, so this event would never run and has not been dispatched.
... ns_error_invalid_arg indicates that event is null.
nsIFactory
exceptions thrown ns_error_no_interface indicates that the requested interface is not supported.
... ns_error_no_aggregation indicates that aggregation is not supported.
nsIFileProtocolHandler
exceptions thrown ns_error_not_available the os does not support such files.
... ns_error_not_available the file is not an internet shortcut.
nsIFrameLoaderOwner
exceptions thrown ns_error_dom_security_err if the swap is not allowed on security grounds.
... ns_error_not_implemented if the swapping logic is not implemented for the either the current frame loader owner or the specified one with which you're trying to swap.
nsIIOService
exceptions thrown ns_error_malformed_uri if url string is not of the right form.
... exceptions thrown ns_error_malformed_uri if uri does not begin with a valid scheme (as defined by rfc 3986) followed by a colon.
nsIModule
exceptions thrown ns_error_factory_not_registered indicates that the requested class is not available.
... ns_error_no_interface indicates that the requested interface is not supported.
nsIOutputStream
ns_error_not_implemented indicates that the stream does not implement this method.
... ns_error_not_implemented indicates that the stream does not have an internal buffer that can be written to directly.
nsIPrincipal
if the load is not allowed the function throws ns_error_dom_bad_uri.
... exceptions thrown ns_error_dom_bad_uri the load is not permitted.
nsIProperties
exceptions thrown ns_error_failure if the property does not exist.
... ns_error_no_interface if the property exists, but does not support the requested interface.
nsISHistory
ns_error_failure error in obtaining history entry for the given index.
... exceptions thrown ns_error_failure numentries is invalid or out of bounds with the size of history.
nsIScriptableInputStream
exceptions thrown ns_error_not_initialized if init() was not called.
...exceptions thrown ns_error_failure if there are not enough bytes available to read acount amount of data.
nsIScriptableUnescapeHTML
exceptions thrown ns_error_failure unable to append the text to the element.
... exceptions thrown ns_error_failure unable to convert the string.
nsISearchEngine
if null, will default to "text/html" exceptions thrown ns_error_invalid_arg if name or value are null.
... ns_error_failure if the search engine is read-only.
nsISessionStore
exceptions thrown this method throws a ns_error_illegal_value exception if the key doesn't exist.
... return value exceptions thrown ns_error_invalid_arg when aindex does not map to a closed window.
nsITaskbarProgress
exceptions thrown ns_error_illegal_value if currentvalue is greater than maxvalue.
... ns_error_invalid_arg if state is state_no_progress or state_indeterminate, and either currentvalue or maxvalue is not 0.
nsIURIFixup
exceptions thrown ns_error_unknown_protocol when we can not get a protocol handler service for the uri scheme.
... ns_error_malformed_uri when the exposable portion of auri is malformed.
nsIUTF8ConverterService
exceptions thrown ns_error_uconv_noconv when there is no decoder for acharset or error code of nsiunicodedecoder in case of conversion failure.
...exceptions thrown ns_error_uconv_noconv when there is no decoder for acharset or error code of nsiunicodedecoder in case of conversion failure.
nsIUUIDGenerator
exceptions thrown ns_error_failure if a uuid cannot be generated (for example if an underlying source of randomness is not available) native code only!generateuuidinplace obtain a new uuid like the generateuuid() method, but place it in the provided nsid pointer instead of allocating a new nsid.
... exceptions thrown ns_error_failure if a uuid cannot be generated (for example if an underlying source of randomness is not available) example generating a uuid var uuidgenerator = components.classes["@mozilla.org/uuid-generator;1"] .getservice(components.interfaces.nsiuuidgenerator); var uuid = uuidgenerator.generateuuid(); var uuidstring = uuid.tostring(); ...
nsIWeakReference
exceptions thrown ns_error_null_pointer the referent no longer exists.
... ns_error_no_interface the requested interface is not available.
nsIWebBrowser
ns_error_invalid_arg one of the arguments was invalid or the object did not implement the interface specified by the iid.
... ns_error_invalid_arg one of the arguments was invalid or the object did not implement the interface specified by the iid.
nsIWebBrowserPersist
exceptions thrown ns_error_invalid_arg one or more arguments was invalid.
... exceptions thrown ns_error_invalid_arg one or more arguments was invalid.
nsIZipReader
exceptions thrown ns_error_illegal_value on many but not all invalid apattern values.
...nputstream(entrypointer); reusablestreaminstance.init(inputstream); var filecontents = reusablestreaminstance.read(entry.realsize); console.log('contenst of file=', filecontents); } else { console.log('is directory, no stream to read'); } } } catch (ex) { console.warn('exception occured = ', ex); if (ex.name == 'ns_error_file_not_found') { services.ww.activewindow.alert('xpi at path does not exist!\n\npath = ' + pathtoxpitoread); } } finally { zr.close(); console.log('zr closed'); } see also nsizipentry nsizipwriter ...
NS ENSURE TRUE
syntax ns_ensure_true( expr, return-value ); usage nsresult mozmyclass::mozstringmucking() { char *foo = new char[123]; ns_ensure_true(foo, ns_error_out_of_memory); // this is equivalent to doing: if (!foo) return ns_error_out_of_memory; // thou shalt not return ns_error_failure..
... int i = 3; ns_ensure_true(i == 3, ns_error_failure); return ns_ok; } char* mozmyclass::dostuff() { char* bar = new char[321]; ns_ensure_true(bar, nsnull); return bar; } ...
XPCOM reference
rss feeds are implemented by nslocalmailfolder.ns ensure successmacrons ensure truemacrons_abort_if_falsethis was removed in bug 1127201ns_addrefmacrons_assertionmacrons_ensure_arg_pointermacrons_errorthrows a assertion (ns_assertion) with the text "error: (error text)", so writes this text to console (stderr) and to debug logs (nspr logging).
... this macro is meant for critical errors; like assertions, ns_errors should not be reachable.ns_if_addrefmacrons_if_releasemacrons_releasemacrons_warningmacronsgetmoduleprocthis function prototype provides the xpcom entry-point into a module.nsiabcard/thunderbird3the nsiabcard interface is used to represent and manipulate cards in the address book.
Setting HTTP request headers
.getservice(components.interfaces.nsiobserverservice); os.addobserver(this, "http-on-modify-request", false); return; } }, queryinterface: function (iid) { if (iid.equals(components.interfaces.nsiobserver) || iid.equals(components.interfaces.nsisupports)) return this; components.returncode = components.results.ns_error_no_interface; return null; }, }; var mymodule = { registerself: function (compmgr, filespec, location, type) { var compmgr = compmgr.queryinterface(components.interfaces.nsicomponentregistrar); compmgr.registerfactorylocation(this.mycid, this.myname, this.myprogid, ...
...myfactory; }, mycid: components.id("{9cf5f3df-2505-42dd-9094-c1631bd1be1c}"), myprogid: "@dougt/myhttplistener;1", myname: "simple http listener", myfactory: { queryinterface: function (aiid) { if (!aiid.equals(components.interfaces.nsisupports) && !aiid.equals(components.interfaces.nsifactory)) throw components.results.ns_error_no_interface; return this; }, createinstance: function (outer, iid) { log("----------------------------> createinstance"); return new myhttplistener(); } }, canunload: function(compmgr) { return true; } }; function nsgetmodule(compmgr, filespec) { return mymodule; } privacy and security good practice a use case ...
Working with Multiple Versions of Interfaces
what happens is that the call to do_createinstance fails with nsresult ns_error_no_interface.
... and this explains our ns_error_no_interface.
FileSystemDirectoryEntry.removeRecursively() - Web APIs
ossamsung internetremoverecursively deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immediately called the error callback with ns_error_dom_security_err.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support 18firefox android no suppo...
...rt 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immediately called the error callback with ns_error_dom_security_err.opera android no support nosafari ios no support nosamsung internet android full support yeslegend full support full support no support no supportnon-standard.
FileSystemDirectoryEntry - Web APIs
yesremoverecursively deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immediately called the error callback with ns_error_dom_security_err.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support 18firefox android no suppo...
...rt 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immediately called the error callback with ns_error_dom_security_err.opera android no support nosafari ios no support nosamsung internet android full support yeslegend full support full support no support no supportexperimental.
FileSystemFileEntry.createWriter() - Web APIs
safari on iossamsung internetcreatewriter deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immediately called errorcallback with the ns_error_dom_security_err error.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support 18firefox android no...
... support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immediately called errorcallback with the ns_error_dom_security_err error.opera android no support nosafari ios no support nosamsung internet android full support yeslegend full support full support no support no supportnon-standard.
FileSystemFileEntry - Web APIs
ith the vendor prefix: webkitcreatewriter deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immediately called errorcallback with the ns_error_dom_security_err error.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support 18firefox android no...
... support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immediately called errorcallback with the ns_error_dom_security_err error.opera android no support nosafari ios no support nosamsung internet android full support yesfilechrome full support 8edge full support 79firefox full support 50ie no support noopera no support nosafari full support ...
Common Pitfalls - Archive of obsolete content
a uri object in almost all cases, when creating a uri object you want to use the newuri method on the nsiioservice interface, like so: javascript: try { var ioserv = components.classes["@mozilla.org/network/io-service;1"] .getservice(components.interfaces.nsiioservice); var uriobj = ioserv.newuri(uristring, uricharset, baseuri); } catch (e) { // may want to catch ns_error_malformed_uri for some applications } c++: nsresult rv; nscomptr<nsiioservice> ioserv = do_getservice("@mozilla.org/network/io-service;1"); ns_ensure_success(rv, rv); nscomptr<nsiuri> uriobj; rv = ioserv->newuri(uristring, uricharset, baseuri, getter_addrefs(uriobj)); if (ns_failed(rv)) { // may want to handle ns_error_malformed_uri for // some applications return rv...
Custom about: URLs - Archive of obsolete content
.io.newchannelfromuriwithloadinfo(uri, asecurity_or_aloadinfo); } else { channel = services.io.newchannel(aboutpage_uri, null, null); } channel.originaluri = auri; return channel; } } class factory { constructor(component) { this.component = component; this.register(); object.freeze(this); } createinstance(outer, iid) { if (outer) { throw cr.ns_error_no_aggregation; } return new this.component(); } register() { cm.registerfactory(this.component.classid, this.component.classdescription, this.component.contractid, this); } unregister() { cm.unregisterfactory(this.component.prototype.classid, this); } } instantiation firefox 4+ now in the startup...
Index - Archive of obsolete content
in calling this method, the editor is created underneath and the event listeners are all prepa if (ns_failed(rv)) return ns_error_failure; // we are not setup??!!
Monitoring WiFi access points - Archive of obsolete content
= "<p>" + count++ + "</p>"; }, onerror: function (value) { alert("error: " +value); }, queryinterface: function(iid) { netscape.security.privilegemanager.enableprivilege('universalxpconnect'); if (iid.equals(components.interfaces.nsiwifilistener) || iid.equals(components.interfaces.nsisupports)) return this; throw components.results.ns_error_no_interface; }, } netscape.security.privilegemanager.enableprivilege('universalxpconnect'); var listener = new test(); var wifi_service = components.classes["@mozilla.org/wifi/monitor;1"].getservice(components.interfaces.nsiwifimonitor); wifi_service.startwatching(listener); </script> </head> <body> <div id="d"><p></p></div> <div id="c"><p></p></div> </body> </html> the nsiwifil...
Editor Embedding Guide - Archive of obsolete content
in calling this method, the editor is created underneath and the event listeners are all prepa if (ns_failed(rv)) return ns_error_failure; // we are not setup??!!
XULRunner tips - Archive of obsolete content
opendelay", 0); pref("browser.download.manager.focuswhenstarting", false); pref("browser.download.manager.flashcount", 2); // pref("alerts.slideincrement", 1); pref("alerts.slideincrementtime", 10); pref("alerts.totalopentime", 4000); pref("alerts.height", 50); if you are missing preferences that a dialog requires, you will get the following errors: component returned failure code: 0x8000ffff (ns_error_unexpected) [nsiprefbranch.getboolpref] error: dialog has no properties source file: chrome://mozapps/content/downloads/u...ontenttype.xul line: 1 enabling password manager these preferences seem to be the default in firefox, however, they are missing in xulrunner.
calICalendarViewController - Archive of obsolete content
related interfaces calicalendarview calidecoratedview example code var myviewcontroller = { queryinterface: function(aiid) { if (!aiid.equals(components.interfaces.calicalendarviewcontroller) && !aiid.equals(components.interfaces.nsisupports)) { throw components.results.ns_error_no_interface; } return this; }, createnewevent: function (acalendar, astarttime, aendtime) { // if we're given both times, skip the dialog if (astarttime && aendtime && !astarttime.isdate && !aendtime.isdate) { var event = createevent(); event.startdate = astarttime; event.enddate = aendtime; event.title = "n...
2006-11-24 - Archive of obsolete content
"component returned failure code: 0x80570016 (ns_error_xpc_gs_returned_failure) [nsijscid.getservice]" nsresult: "0x80570016 (ns_error_xpc_gs_returned_failure)" location: "js frame :: chrome://modzilla/content/js/pkg_zillacom.js :: <top_level> :: line 1202" data: no] he is running xulrunner v1.8.0.4.
2006-12-08 - Archive of obsolete content
however, the c++ call that's supposed to be invoking the method on the javascript object is returning with 0x80004005 (ns_error_failure).
SAX - Archive of obsolete content
rablewhitespace: function(whitespace) { // don't care }, startprefixmapping: function(prefix, uri) { // don't care }, endprefixmapping: function(prefix) { // don't care }, // nsisupports queryinterface: function(iid) { if(!iid.equals(components.interfaces.nsisupports) && !iid.equals(components.interfaces.nsisaxcontenthandler)) throw components.results.ns_error_no_interface; return this; } }; start parsing the xml reader component can parse xml from a string, an nsiinputstream, or asynchronously via the nsistreamlistener interface.
Adding a new event
if all information of the event is stored by its internal event, c++ event handlers can access them with following code: ns_imethodimp aneventlistener::handleevent(nsidomevent* aevent) { internalfooevent* internalevent = aevent->getinternalnsevent()->asfooevent(); if (ns_warn_if(!internalevent)) { return ns_error_unexpected; } dosomethingwith(internalevent->mbar); aevent->preventdefault(); return ns_ok; } implement dom event class generate dom event implementation if it's possible if you're creating simple dom event class, it might be generated automatically.
Creating Custom Events That Can Pass Data
nsdomevent* it = new nsdommyevent(aprescontext, aevent); if (nsnull == it) { return ns_error_out_of_memory; } return callqueryinterface(it, adomevent); } in general though i'd strongly recommend using a function the way that everyone else does.
Commenting IDL for better documentation
* * @throws ns_error_failure unable to locate the requested quote.
Overview of Mozilla embedding APIs
public return codes ns_succeeded ns_error_failure ns_error_not_implemented public functions the following functions are available from the xpcom dll.
Embedding Tips
at startup use the category manager to register properties of the global object in javascript like this: nscomptr<nsicategorymanager> catman = do_getservice(ns_categorymanager_contractid); if (!catman) return ns_error_failure; nsxpidlcstring previous; catman->addcategoryentry(javascript_global_property_category, "my_prop_name", "my_prop_contract_id", pr_true, pr_true, getter_copies(previous)); this will cause a component with the contract id my_prop_contract_id to be lazily created when the my_prop_name is resolved in any javascript window scope.
Mozilla Port Blocking
"access to the port number given has been disabled for security reasons." "establishing a connection to an unsafe or otherwise banned port was prohibited" "0x804b0013 (ns_error_port_access_not_allowed)" if your product or web site uses a port which is blocked by mozilla's default port blocking rules, you can either change the port of your service to a unblocked value (recommended if possible) or ask your mozilla users to enable the port.
Using the Places annotation service
name, adata, adatalen, amimetype); getitemannotationstring(aitemid, aname); getitemannotationint32(aitemid, aname); getitemannotationint64(aitemid, aname); getitemannotationdouble(aitemid, aname); getitemannotationbinary(aitemid, aname, adata, adatalen, amimetype); from javascript: getpageannotation(auri, aname); getitemannotation(aitemid, aname); these functions will return/throw ns_error_not_available if the annotation requested does not exist.
Aggregating the In-Memory Datasource
aresult) return ns_error_null_pointer; if (aiid.equals(nscomtypeinfo<nsimyinterface>::getiid()) || aiid.equals(nscomtypeinfo<nsisupports>::getiid())) { *aresult = ns_static_cast(nsiglobalhistory*, this); } else if (aiid.equals(nscomtypeinfo<nsirdfdatasource>::getiid())) { return minner->queryinterface(aiid, aresult); } else { *aresult = nsnull; return ns_nointerface; } ns_addref(ns_s...
Finishing the Component
here is the complete implementation of the shouldload() method: ns_imethodimp weblock::shouldload(print32 contenttype, nsiuri *contentlocation, nsisupports *ctxt, nsidomwindow *window, prbool *_retval) { if (!contentlocation) return ns_error_failure; nsembedcstring scheme; contentlocation->getscheme(scheme); if (strcmp("http", scheme.get()) != 0 && strcmp("https", scheme.get()) != 0 && strcmp("ftp", scheme.get()) != 0) { // this isn't a type of uri that we deal with *_retval = pr_true; return ns_ok; } nsembedcstring hosttoload; contentlocation->gethost(hosttoload); // assume failure.
Introduction to XPCOM for the DOM
return ns_ok; } ns_imethodimp nshtmldocument::getneat(prbool *aneat) { if(!aneat) { return ns_error_null_pointer; } nsresult rv = fabian(); if( rv == ns_ok ) { *aneat = pr_true; } else { *aneat = pr_false; } return ns_ok; } this code is of course written in nshtmldocument.cpp.
Components.Exception
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."); ...
Components.isSuccessCode
if (!components.issuccesscode(statuscode)) copyfailed = true; }, queryinterface: function(aiid) { if (aiid.equals(ci.nsirequestobserver) || aiid.equals(ci.nsisupports)) return this; throw cr.ns_error_no_interface; } }; var copier = cc["@mozilla.org/network/async-stream-copier;1"] .createinstance(ci.nsiasyncstreamcopier); copier.init(instream, outstream, null, true, false, 8192, true, true); copier.asynccopy(copyobserver, null); } ...
HOWTO
"component returned failure code: 0x80040111 (ns_error_not_available) [nsixpccomponents_utils.import]" nsresult: "0x80040111 (ns_error_not_available)" location: "js frame :: file.js :: <top_level> :: line 12" data: no] solution 1 var loader = components.classes["@mozilla.org/moz/jssubscript-loader;1"] .getservice(components.interfaces.mozijssubscriptloader); loader.loadsubscript("chrome://myall/content/file.jsm"); see: http://mxr.mozilla.org...
NS_InitXPCOM2
some of the possible errors are documented below: ns_error_not_initialized indicates that static globals were not yet initialized, which may happen if this method is called before xpcom's static initialization code executes.
NS_InitXPCOM3
some of the possible errors are documented below: ns_error_not_initialized indicates that static globals were not yet initialized, which may happen if this method is called before xpcom's static initialization code executes.
NS_NewLocalFile
ns_error_file_unrecognized_path indicates that the specified path is invalid.
NS_NewNativeLocalFile
ns_error_file_unrecognized_path indicates that the specified path is invalid.
nsresult
if (something) { return ns_error_failure; } ...
imgICache
ns_error_not_available if a uri was unable to be removed from the cache.
imgIContainer
exceptions thrown ns_error_not_available if the animated state cannot be determined.
mozIAsyncHistory
exceptions thrown ns_error_invalid_arg passing in null for aplaceinfo.
mozISpellCheckingEngine
note: setting this value to a value that doesn't match an existing dictionary throws a ns_error_file_not_found exception.
mozIStorageStatement
note: starting in gecko 2.0, this method returns ns_error_unexpected if the specified mozistoragebindingparamsarray is empty.
Children
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
ExtendSelection
void extendselection(); exceptions thrown ns_error_not_implemented always.
FirstChild
attribute nsiaccessible firstchild; exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
GetAccessibleRelated
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.ns_error_not_implemented indicates that the given relation type is unsupported see also nsiaccessible.getrelations() nsiaccessible.relationscount nsiaccessible.getrelation() ...
GetActionName
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.ns_error_invalid_arg indicates that the given index is our of range.
GetChildAt
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
GetKeyBindings
exceptions thrown ns_error_invalid_arg the given index doesn't correspond to default action (not zero).
GetRelation
exception thrown ns_error_invalid_arg indicates that the given index is invalid.
GetState
exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
LastChild
attribute nsiaccessible lastchild; exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
NextSibling
attribute nsiaccessible nextsibling; exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
Parent
attribute nsiaccessible parent; exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
PreviousSibling
attribute nsiaccessible previoussibling; exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
SetSelected
void setselected( in boolean aisselected ); parameters aisselected[out] the current selection exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
TakeSelection
void takeselection(); exceptions thrown ns_error_failure indicates that the accessible is unattached from the accessible tree.
nsIAccessibleRelation
exceptions thrown ns_error_invalid_arg indicates the given index is out of range.
nsIAlertsService
exceptions thrown ns_error_not_available unable to display the notification; this may happen, for example, on mac os x if growl is not installed.
nsIAsyncVerifyRedirectCallback
if this is ns_error_abort, the redirect has been vetoed.
nsIAuthPromptProvider
exceptions thrown ns_error_not_available if no prompt is allowed or available for the given reason.
nsICache
if a cache entry is waiting to be validated by another cache descriptor (so no new cache descriptors for that key can be created), opencacheentry() will return ns_error_cache_wait_for_validation in non-blocking mode.
nsICacheListener
void oncacheentrydoomed( in nsresult status ); parameters status the status is ns_ok when the entry was doomed, or ns_error_not_available when there is no such entry.
nsICacheService
exceptions thrown ns_error_not_implemented this method is deprecated.
nsICacheSession
if blockingmode is set to false, it will return ns_error_cache_wait_for_validation rather than block when another descriptor has been given write access but hasn't validated the entry yet.
nsIClassInfo
violates the xpcom interface guidelines exceptions thrown ns_error_not_available if the class does not have a classid contractid string a contractid through which an instance of this class can be created, or null.
nsICommandLineRunner
exceptions thrown ns_error_abort thrown when the handler aborts.
nsIConverterOutputStream
exceptions thrown ns_error_loss_of_significant_data if areplacementcharacter is not encodable in the selected character encoding and an attempt is made to write the character.
nsIDBChangeListener
readchanged: function(ainstigator) {}, onjunkscorechanged: function(ainstigator) {}, onhdrpropertychanged: function(ahdrtochange, aprechange, astatus, ainstigator) {}, onevent: function(adb, aevent) {}, queryinterface: function(aiid) { if (!aiid.equals(components.interfaces.nsidbchangelistener) && !aiid.equals(components.interfaces.nsisupports)) throw components.results.ns_error_no_interface; return this; } }; and to attach it in thunderbird, we must call addlistener on a nsidbchangeannouncer, typically through a nsimsgdatabase.
nsIDNSRequest
the listener will passed to asyncresolve will be notified immediately with a status code of ns_error_abort.
nsIDNSService
exceptions thrown ns_error_unknown_host if host could not be resolved.
nsIDOMChromeWindow
void beginwindowmove( in nsidomevent mousedownevent ); parameters mousedownevent exceptions thrown ns_error_not_implemented if the operating system does not support this method.
nsIDOMWindow
when setting this attribute, an ns_error_not_implemented error may be returned by implementations not supporting zoom.
nsIDirectoryEnumerator
ns_error_failure if the directory close failed.
nsIDocShell
when setting this attribute, a ns_error_not_implemented error may be returned by implementations not supporting zoom.
nsIDownloadManagerUI
exceptions thrown ns_error_unexpected the user interface isn't currently open.
nsIDroppedLinkHandler
exceptions thrown ns_error_dom_security_err error will be thrown and the event canceled if the receiving target should not load the uri for security reasons.
nsIFilePicker
exceptions thrown ns_error_failure if you try to read this attribute.
nsIInputStream
ns_error_not_implemented indicates that the stream does not have an internal buffer that can be accessed directly.
nsIInterfaceRequestor
exceptions thrown ns_error_no_interface the requested interface is not available.
nsIMsgAccount
exceptions thrown ns_error_already_opened if it is called more then once removeidentity() removes an identity from this account.
nsIMsgDatabase
exceptions thrown ns_error_file_target_does_not_exist afoldername doesn't exist and acreate was false.
nsINavBookmarkObserver
queryinterface: function(iid) { if (iid.equals(ci.nsinavbookmarkobserver) || iid.equals(ci.nsinavbookmarkobserver_mozilla_1_9_1_additions) || iid.equals(ci.nsisupports)) { return this; } throw cr.ns_error_no_interface; } see also places manipulating bookmarks using places nsinavbookmarksservice ...
nsINavHistoryObserver
queryinterface: function(iid) { if (iid.equals(ci.nsinavhistoryobserver) || iid.equals(ci.nsinavhistoryobserver_mozilla_1_9_1_additions) || iid.equals(ci.nsisupports)) { return this; } throw cr.ns_error_no_interface; } see also nsinavhistoryresult ...
nsIPrivateBrowsingService
changing this value while handling one of the notifications generated by the private browsing service throws an ns_error_failure exception.
nsIProfile
exceptions thrown ns_error_failure a profile already exists with the name newname.
nsIProfileLock
exceptions thrown ns_error_unexpected the profile isn't locked.
nsIPropertyBag
exceptions thrown ns_error_failure if a property with that name doesn't exist.
nsIProtocolProxyService
exceptions thrown ns_error_not_available if there is no alternate proxy available.
nsIScriptableUnicodeConverter
throws ns_error_uconv_noconv if the requested charset is not supported.
nsISelectionController
return value if aoutenabled==null, returns ns_error_invalid_arg else ns_ok.
nsISimpleEnumerator
ns_error_failure if there are no more elements to enumerate.
nsISocketTransportService
this will fail with the error code ns_error_not_available if the maximum number of sockets is already reached.
nsISupports
exceptions thrown ns_error_no_interface the requested interface is not available.
nsIVariant
return value if the conversion succeeds, ns_ok is returned, otherwise ns_error_cannot_convert_data is returned.
nsIWebContentHandlerRegistrar
otherwise ns_error_dom_syntax_err will be thrown.
nsIWebSocketChannel
note: implementations should throw ns_error_already_opened if the websocket connection is reopened.
nsIWritablePropertyBag
exceptions thrown ns_error_failure if a property with that name doesn't exist.
nsIXPCException
message - a custom message set by the thrower (defaults to 'exception') result - the nsresult associated with this exception (defaults to components.results.ns_error_failure) stack - the stack chain (defaults to the current stack) data - additional data object of your choice (defaults to null) inner - an inner exception that triggered this, if available ...
nsIXULRuntime
may throw ns_error_not_available.
nsIXmlRpcClient
return value will be converted as follows: i4 or int: nsisupportsprint32 boolean: nsisupportsprbool string: nsisupportscstring double: nsisupportsdouble datetime.iso8601: nsisupportsprtime base64: nsisupportscstring array: nsisupportsarray struct: nsidictionary faults (server side errors) are indicated by returning ns_error_failure.
NS_ENSURE_ARG_POINTER
summary macro returns ns_error_invalid_pointer if the macro argument evaluates to false and shows a warning (ns_warning) in this case.
NS_WARNING
contrary to ns_error this is meant for noncritical errors.
Using nsIDirectoryService
c++ nscomptr<nsifile> dir; ns_getspecialdirectory(prop, getter_addrefs(dir)); if (!dir) return ns_error_failure; javascript: var file = components.classes["@mozilla.org/file/directory_service;1"] .getservice(components.interfaces.nsiproperties) .get("profd", components.interfaces.nsifile); (the example is taken from the code snippets section of this site.) adding a location: there are currently two ways to add a file location to the directory service: dire...
XPCOM ABI
open the error console (accessible through tools | error console) and evaluate the following javascript code: components.classes["@mozilla.org/xre/app-info;1"] .getservice(components.interfaces.nsixulruntime) .xpcomabi if either the cpu architecture or the c++ compiler are unknown, the application wouldn't have an xpcom abi string and attempts to get it will result in error ns_error_not_available.
wrappedJSObject
// constructor function helloworld() { }; helloworld.prototype = { hello: function() { return "hello world!"; }, queryinterface: function(aiid) { if (!aiid.equals(components.interfaces.nsisupports) && !aiid.equals(components.interfaces.nsihelloworld)) throw components.results.ns_error_no_interface; return this; } }; xpconnect wrapping now let's get a reference to our component.
Address Book examples
let card = collection.cardforemailaddress("foo@bar.invalid.com"); note: both of these functions may raise an ns_error_not_implemented exception if the collection has not implemented that function.
nsIMsgCloudFileProvider
this might change in the future, but as it stands, this function can simply return ns_error_not_implemented unless there are plans to call createnewaccount from the management or settings xhtml files.
WebIDL bindings
when throwing for an unforeseen condition, the exception will be reported to the console, and a sanitized ns_error_unexpected exception will be thrown to the calling content script, with the file/line of the content code that invoked your api.
Mozilla
for example, by using components.results.ns_error_not_initialized firefox here you can learn about how to contribute to the firefox project and you will also find links to information about the construction of firefox add-ons, using the developer tools in firefox, and other topics.
CanvasRenderingContext2D.drawImage() - Web APIs
ns_error_not_available the image is not loaded yet.
Document.createCDATASection() - Web APIs
will throw a ns_error_dom_invalid_character_err exception if one tries to submit the closing cdata sequence ("]]>") as part of the data, so unescaped user-provided data cannot be safely used without with this method getting this exception (createtextnode() can often be used in its place).
Document.write() - Web APIs
WebAPIDocumentwrite
for example: <script> document.write("<h1>main title</h1>") </script> note: document.write() and document.writeln do not work in xhtml documents (you'll get an "operation is not supported" [ns_error_dom_not_supported_err] error in the error console).
Document.writeln() - Web APIs
WebAPIDocumentwriteln
note: document.writeln (like document.write) does not work in xhtml documents (you'll get a "operation is not supported" (ns_error_dom_not_supported_err) error on the error console).
Element.setAttributeNodeNS() - Web APIs
note that if you try to set without cloning the node, mozilla gives an ns_error_dom_inuse_attribute_err "attribute already in use" error, as the dom requires cloning for attr to be reused (unlike other nodes which can be moved).
Using the Web Storage API - Web APIs
ue; } catch(e) { return e instanceof domexception && ( // everything except firefox e.code === 22 || // firefox e.code === 1014 || // test name field too, because code might not be present // everything except firefox e.name === 'quotaexceedederror' || // firefox e.name === 'ns_error_dom_quota_reached') && // acknowledge quotaexceedederror only if there's something already stored (storage && storage.length !== 0); } } and here is how you would use it: if (storageavailable('localstorage')) { // yippee!
WindowOrWorkerGlobalScope.setInterval() - Web APIs
, 1500, "1"); // prints "undefined" after 1,5 seconds // passing the 'this' object with .call won't work // because this will change the value of this inside settimeout itself // while we want to change the value of this inside myarray.mymethod // in fact, it will be an error because settimeout code expects this to be the window object: settimeout.call(myarray, myarray.mymethod, 2000); // error: "ns_error_xpc_bad_op_on_wn_proto: illegal operation on wrappednative prototype object" settimeout.call(myarray, myarray.mymethod, 2500, 2); // same error as you can see there are no ways to pass the this object to the callback function in the legacy javascript.
WindowOrWorkerGlobalScope.setTimeout() - Web APIs
settimeout.call(myarray, myarray.mymethod, 2.0*1000); // error: "ns_error_xpc_bad_op_on_wn_proto: illegal operation on wrappednative prototype object" settimeout.call(myarray, myarray.mymethod, 2.5*1000, 2); // same error possible solutions a common way to solve the problem is to use a wrapper function that sets this to the required value: settimeout(function(){myarray.mymethod()}, 2.0*1000); // prints "zero,one,two" after 2 seconds settimeout(function(){myarray.my...
Introduction to using XPath in JavaScript - XPath
note however, that if the document is mutated (the document tree is modified) between iterations that will invalidate the iteration and the invaliditeratorstate property of xpathresult is set to true, and a ns_error_dom_invalid_state_err exception is thrown.