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

NS ENSURE SUCCESS

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;
}

Document Tags and Contributors

 Contributors to this page: teoli, Biesi, Callek, Bastiaan Jacques
 Last updated by: Biesi,