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,