21
#ifndef DRIZZLED_ERROR_H
22
#define DRIZZLED_ERROR_H
25
24
#include <boost/unordered_map.hpp>
26
#include <drizzled/common_fwd.h>
27
27
#include <drizzled/definitions.h>
28
28
#include <drizzled/error/level_t.h>
29
29
#include <drizzled/error_t.h>
30
30
#include <drizzled/identifier.h>
31
31
#include <drizzled/visibility.h>
36
35
/* Max width of screen (for error messages) */
37
36
#define SC_MAXWIDTH 256
48
47
typedef std::pair<std::string, std::string> value_type;
49
typedef boost::unordered_map<drizzled::error_t, value_type> ErrorMessageMap;
48
typedef boost::unordered_map<error_t, value_type> ErrorMessageMap;
53
52
// Insert the message for the error. If the error already has an existing
54
53
// mapping, an error is logged, but the function continues.
55
void add(drizzled::error_t error_num, const std::string &error_name, const std::string &message);
54
void add(error_t error_num, const std::string &error_name, const std::string &message);
57
// If there is no error mapping for the error_num, ErrorStringNotFound is raised.
58
const std::string &find(drizzled::error_t error_num) const;
56
const std::string* find(error_t error_num) const;
60
58
static const ErrorMessageMap& get_error_message_map();
66
64
ErrorMessageMap mapping_;
69
typedef void (*error_handler_func)(drizzled::error_t my_err,
67
typedef void (*error_handler_func)(error_t my_err,
72
70
extern error_handler_func error_handler_hook;
74
72
// TODO: kill this method. Too much to do with this branch.
75
73
// This is called through the ER(x) macro.
76
DRIZZLED_API const char * error_message(drizzled::error_t err_index);
74
DRIZZLED_API const char * error_message(error_t err_index);
78
76
// Adds the message to the global error dictionary.
79
void add_error_message(drizzled::error_t error_code, const std::string &error_name,
77
void add_error_message(error_t error_code, const std::string &error_name,
80
78
const std::string& message);
81
79
#define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
85
void access(drizzled::identifier::User::const_reference user);
86
void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Schema::const_reference schema);
87
void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Table::const_reference table);
83
void access(const identifier::User&);
84
void access(const identifier::User&, const identifier::Schema&);
85
void access(const identifier::User&, const identifier::Table&);
89
87
const std::string &verbose_string();
90
88
error::level_t &verbosity();
96
94
DRIZZLED_API void my_error(const std::string &ref, error_t nr, myf MyFlags= MYF(0));
97
DRIZZLED_API void my_error(error_t nr, drizzled::Identifier::const_reference ref, myf MyFlags= MYF(0));
95
DRIZZLED_API void my_error(error_t nr, const Identifier&, myf MyFlags= MYF(0));
98
96
DRIZZLED_API void my_error(error_t nr);
99
97
DRIZZLED_API void my_error(error_t nr, myf MyFlags, ...);
100
void my_message(drizzled::error_t my_err, const char *str, myf MyFlags);
101
void my_printf_error(drizzled::error_t my_err, const char *format,
98
void my_message(error_t my_err, const char *str, myf MyFlags);
99
void my_printf_error(error_t my_err, const char *format,
102
100
myf MyFlags, ...)
103
101
__attribute__((format(printf, 2, 4)));
105
103
} /* namespace drizzled */
107
#endif /* DRIZZLED_ERROR_H */