sdskv-common.hpp 947 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#ifndef __SDSKV_COMMON_HPP
#define __SDSKV_COMMON_HPP

namespace sdskv {

const char const sdskv_error_messages[] = {
    "",
    "Allocation error",
    "Invalid argument",
    "Mercury error",
    "Could not create database",
    "Invalid database name",
    "Invalid database id",
    "Invalid provider id",
    "Error writing in the database",
    "Unknown key",
    "Provided buffer size too small",
    "Error erasing from the database",
    "Migration error",
    "Function not implemented",
    "Invalid comparison function",
    "REMI error",
    "Argobots error"
};

class exception : public std::exception {

    std::string m_msg;
    int m_error;

    static const 

    public:

    exception(int error)
    : m_msg(std::string("[SDSKV] ") + sdskv_error_messages[-error])
    , m_error(error) {}

    const char* what() const {
        return m_msg.c_str();
    }

    int error() const {
        return m_error;
    }
};

}

#endif