Summary
Macro
Returns return-value if NS_FAILED(nsresult) evaluates to true, and shows a warning on stderr in that case.
Syntax
NS_ENSURE_SUCCESS(nsresult, return-value);
Usage
nsresult mozMyClass::MozStringMucking() { nsresult rv = NS_CStringCopy(mDestString, mSrcString); NS_ENSURE_SUCCESS(rv, rv); // this is the same as doing: nsresult rv = NS_CStringCopy(mDestString, mSrcString); if (NS_FAILED(rv)) return rv; return NS_OK; }