The library reports an error through one of two channels.
- A call that fails throws an exception to its caller: JavaException when the Java code of the dxFeed Graal SDK throws, GraalException when the call cannot enter the isolate, InvalidArgumentException, RuntimeException. The Java exception belongs to the call that failed, a later call does not get it, even when the failure is reported by a result (System::setProperty() returns false). When an SDK function that has no null result returns null without a Java exception, the call throws RuntimeException.
- An error without a caller goes to ErrorManager. Such an error happens in the code that the library runs on its own: a callback of the dxFeed Graal SDK (events of a subscription, a state change of an endpoint or of an instrument profile connection, a change of a subscription, instrument profiles of a collector, the events of a model). An exception of that code would otherwise terminate the process, and the caller's thread could not see it anyway: the callback runs on a thread of the SDK.
- A release that fails goes to ErrorManager as well: a destructor or a function that frees the native data of the SDK (for example, the destructor of a subscription or of a model that closes it) does not throw. From the start of the shutdown of the library (dxfcpp::shutdown(), the exit of the process) a failure of a release is not reported: the SDK is being closed or is closed already.
- A failed creation of the Graal isolate (an invalid argument of System::setIsolateArguments() or of the DXFCPP_ISOLATE_ARGUMENTS environment variable, see Isolate arguments) is reported to the caller of the first call that needs Java and of every next one: GraalException with the numeric code, its text and the reason. The library does not try to create the isolate again. System::getProperty() and System::setProperty() throw it too, instead of returning an empty string or false; the functions of the C API return DXFC_EC_ERROR. The messages never contain the values of the arguments.
- A warning is reported from inside a call that goes on (for example, a fromTime in the future given to a TimeSeriesTxModel, a candle symbol string without a period given to CandleSymbol::valueOf(), see Candle symbols; a slow listener of a subscription, see Listeners and threads; a subscription without events while its endpoint is connected, when its silence watchdog is on, see DXFeedSubscription::setSilenceWatchdog()): the call does not throw and does not change its result. The library reports it with ErrorManager::reportWarning(), and it has the level ErrorInfo::Level::WARN, while the errors have ErrorInfo::Level::ERROR (ErrorInfo::level). A warning shares the handler, the journal and ErrorManager::getLastError() with the errors.
- An INFO message (ErrorInfo::Level::INFO) is not a problem: the library reports it on its own, once per process, when the first endpoint is created (DXEndpoint::create(), DXEndpoint::Builder::build(), DXEndpoint::getInstance(), DXFeed::getInstance(), DXPublisher::getInstance()). It names the versions of the dxFeed Graal C++ API and of the dxFeed Graal Native SDK and the platform, the first thing to send to the support: [dxfcpp] INFO #1 DXEndpoint: dxFeed Graal C++ API v9.0.0, dxFeed Graal Native SDK 3.18.0, Windows x86_64(16 cores). The version of QD follows in the log of the SDK: Using QDS-<version>, (C) Devexperts.
ErrorManager passes each error, warning and INFO message to the handler and keeps the last ones in a journal:
Events of the types that the C++ API does not implement (for example, EventTypeEnum::CONFIGURATION) are skipped in the event callbacks: the other events of the batch are delivered, and one error per type and batch is reported with the number of the skipped events. A listener of a subscription is not called when all the events of a batch are skipped.
ErrorManager works during the exit of the process and after dxfcpp::shutdown(): it is never destroyed and does not call the SDK. The handler can be called at exit from a thread of the SDK while the static objects of the program are being destroyed, as the listeners can (see dxfcpp::shutdown()).
dxfcpp::ErrorManager::setHandler([](const dxfcpp::ErrorInfo &error) {
myLogger.error(error.toString());
});