Skip to content

Exceptions for Error Reporting

williamfgc edited this page May 1, 2017 · 7 revisions
  1. Debug mode: Exceptions thrown by the code (no by STL functions) must be inside a debug mode condition set in the ADIOS class constructor. Applications are encourages to turn these on when integrating with ADIOS2.
  2. Standard exception: Throw C++ standard exceptions for error handling, do not throw integers. This is helpful as it allows handling of different exception types in different ways. In rare cases a custom exceptions must be defined/declared.
    • Don't
      •  throw   1;
    • Do
      •  throw   std::invalid_argument ( "ERROR: group was not   
                                previously declared, in call to Write" );
  3. Document exceptions: All error exceptions must start with "ERROR: ". Use informative and precise messages for exception handling to complement the nature of the exception to help the user identify and fix the issue.
    • Don't
      •  throw    std::invalid_argument  (   "ERROR: invalid input for CompressionParameter"  );
    • Do
      •  throw    std::invalid_argument  (   "ERROR: bzip2 CompressionParameter must be an unsigned int between 0 and 9, in call to Compress""  );