Commit c464988e authored by Matthieu Dorier's avatar Matthieu Dorier

error message array is now in sdskv-common.h

parent 8aef1dfb
......@@ -40,6 +40,28 @@ typedef uint64_t sdskv_database_id_t;
#define SDSKV_ERR_REMI -15 /* REMI-related error */
#define SDSKV_ERR_ARGOBOTS -16 /* Argobots related error */
#define SDSKV_ERR_KEYEXISTS -17 /* Put operation would override data */
#define SDSKV_ERR_END -18 /* End of range for valid error codes */
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",
"Key exists"
};
#if defined(__cplusplus)
}
......
......@@ -5,27 +5,6 @@
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",
"Key exists"
};
/**
* @brief Exception thrown when an sdskv call fails with a return code != 0.
*/
......@@ -38,7 +17,7 @@ class exception : public std::exception {
exception(int error)
: m_error(error) {
if(error < 0 && error >= -16) {
if(error < 0 && error > SDSKV_ERR_END) {
m_msg = std::string("[SDSKV] ") + sdskv_error_messages[-error];
} else {
m_msg = std::string("[SDSKV] Unknown error code ") + std::to_string(error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment