Inspirel banner

Programming Distributed Systems with YAMI4

8.3.1 Errors

The C++ core library uses result codes for reporting the outcome of each operation. Result codes are defined in the enumeration type yami::core::result. The rationale for this policy is that exceptions are explicitly forbidden by the coding standard which was used for development of the core library.

The Ada and C++ general-purpose libraries use exceptions for reporting all errors.

The Ada exceptions Runtime_Error and Logic_Error are defined in package YAMI. Every time any of these two exceptions is raised, its error message is filled with human-readable explanation of the exception reason.

The C++ exception types yami_runtime_error and yami_logic_error are defined in the yami namespace. They are derived from standard exception types std::runtime_error and std::logic_error and can be therefore handled at the standard root std::exception type:

catch (const std::exception & e)
{
    std::cerr << "error: " << e.what() << std::endl;
}

The Java library uses exceptions for reporting errors. There are several exception types:

The above exception classes are derived from RuntimeException and are thrown as a result of improper use of the library and indicate programming errors on the user side.

In addition, the YAMIIOException class, derived from IOException, represents run-time errors that do not result from the improper use of the library, but are rather related to communication problems that are not necessarily under programmer's control. These are also errors that have some chance of being corrected with proper fail-over, depending on the particular use case.

The .NET library uses an exception hierarchy that is very similar to the Java one. The only difference is that the exception classes listed above inherit from the common ExceptionBase type, which is rooted in the standard System.Exception class. The YAMIIOException class that represents run-time errors related to communication problems, also inherits from ExceptionBase.

The Python library similarly uses exceptions for reporting errors - the YAMIError class is universally used for all such reports.