CppWAMP
C++11 client library for the WAMP protocol
|
This page describes how error handling is done via ErrorOr
.
Whenever an asynchronous wamp::Session operation fails, it will emit a wamp::ErrorOr that contains a std::error_code
instead of an actual result.
The wamp::ErrorOr::value method would normally be used to retrieve the underlying result of the asynchronous operation. If the ErrorOr
instead contains an error, ErrorOr::value
will throw a wamp::error::Failure exception. Since Failure
derives from std::system_error
, it contains a std::error_code
that represents the cause of the error.
Example using error codes:
Example using exceptions:
An error code can either belong to std::generic_category
, or to one of the error categories defined by the library in <cppwamp/error.hpp>
:
Error category | Values | Used for reporting |
---|---|---|
wamp::SessionCategory | wamp::SessionErrc | WAMP session errors |
wamp::ProtocolCategory | wamp::ProtocolErrc | invalid WAMP messages |
wamp::TransportCategory | wamp::TransportErrc | general transport layer errors |
wamp::RawsockCategory | wamp::RawsockErrc | raw socket transport errors |
std::generic_category | std::errc | OS-level socket errors |
Note that Session
will always throw wamp::error::Logic exceptions whenever preconditions are not met. Preconditions for API functions are listed in this reference documentation.
Next: Remote Procedure Calls