Exceptions

Layered file protocols uses exceptions to signal errors - errors automatically propagate between layers, and are intercepted at the C-API boundary. When one of the exceptions described here are raised, an error message for with lfp_errormsg(), is set, and the exception is converted to the corresponding error code.

// Example protocol where all records start with 'b'
auto err = protocol->readinto(buf, len, &nread);
if (err != LFP_OK)
   throw lfp::protocol_fatal("Truncated record");
if (buf[0] != 'b') {
   auto msg = "Record does not start with 'b'";
   throw lfp::protocol_fatal(msg);
}

#include <protocol.hpp>

class error : public std::runtime_error

Base class for lfp exceptions.

group exceptions

Functions

error not_implemented(const std::string &msg)
error leaf_protocol(const std::string &msg)
error not_supported(const std::string &msg)
error io_error(const std::string &msg)
error runtime_error(const std::string &msg)
error invalid_args(const std::string &msg)
error protocol_fatal(const std::string &msg)
error protocol_failed_recovery(const std::string &msg)
error unexpected_eof(const std::string &msg)