nsresult

The nsresult data type is a strongly-typed enum used to represent a value returned by an XPCOM function; these are typically error or status codes. For a list of defined result values, see Error codes returned by Mozilla APIs.

Note: On compilers that do not support strongly-typed enums (that is, compilers that don't support this feature of C++11), it falls back to being an unsigned 32-bit integer, as in past versions of Gecko.

Note: Prior to Gecko 19.0, nsresult was not strongly typed. As a result, it was possible for code to misuse it, such as returning an nsresult value from a function whose signature indicates it returns a boolean.

Because nsresult is strongly typed, code like the following will result in an error at compile time:

bool foo() {
  ...
  if (something) {
    return NS_ERROR_FAILURE;
  }
  ...
}

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, kscarfone, ethertank
 Last updated by: Sheppy,