Encoded Error Code

last modified: December 8, 2010

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.


Loading...