Share

Message Reporting in Executor SDK

C++ Exceptions

Methods from the Executor SDK classes never throw C++ exceptions. If an internal, system or memory error is detected during the execution of a method from the SDK, the error status will be reported to the caller using the returned value. The documentation for each method indicates how such an error will be reported.

Additional information related to the error, its source and its cause(s) can also be reported to the Workspace's onReportedMessage() method. You generally have no way of determining whether the cause of a method's unexpected failure is internal to the SDK, or whether it is a system or memory allocation error, unless it is explicitly reported via the workspace's onReportedMessage() method.

If an error is detected when building an instance of a class defined in the Executor SDK, the instance will remember its invalid state, it will report it by returning false from its isValid() method, and all future operations on this invalid instance will fail.

makeOwner template

To make sure that the isValid() method is called on any instance right after its constructor returns, makeOwner<>() factory template methods have been added to the SDK. These are defined in the file Factory.h. Each factory template method can be used to create a new object from class T, and the method will automatically validate it with the expression T::isValid() after its construction. If the object has been successfully created and if it is valid, then an Owner<T> instance pointing to a newly created object from class T is returned, and the caller can then store the returned Owner<T> instance and begin to use it. Otherwise, the makeOwner<>() template method throws an exception and the caller is responsible to catch and handle such exception.

Please refer to the BifrostGraph::Executor::makeOwner<> class template in the API reference section.

onReportedMessage method

The Workspace class has an onReportedMessage() virtual method that is used by the Executor SDK to notify you that a message was reported by the Workspace, its Library, a GraphContainer or a Job.

The default implementation of this method writes information messages (MessageCategory::kInfo) and warning messages (MessageCategory::kWarning) to the output stream object std::cout, and writes error messages (MessageCategory::kError) to the output stream object std::cerr. You can override the onReportedMessage() method to customize what you want to be done when it is called by the Executor SDK.

Please refer to the BifrostGraph::Executor::Workspace class in the API reference section for detailed information about its onReportedMessage() method.

Was this information helpful?