Encoded Error Code

In this variant of the ErrorCode pattern, the actual error is encoded in the return code. Many APIs tend to do this. The return code is a value from an enumeration. So the idiom looks like:

  rv_Error e = rv_call(&result,a,b,c);
  if ( e!=RV_OK ) {
    fprintf(stderr,"error %d, %s\n", e, rv_ErrorText(e));
    exit(1);
  }
COM's HRESULT return code takes this even further, dividing the return code into specific bit fields, each with a specific function.


EditText of this page (last edited December 8, 2010) or FindPage with title or text search