00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <string>
00024 #include <boost/unordered_map.hpp>
00025
00026 #include <drizzled/common_fwd.h>
00027 #include <drizzled/definitions.h>
00028 #include <drizzled/error/priority_t.h>
00029 #include <drizzled/error_t.h>
00030 #include <drizzled/identifier.h>
00031 #include <drizzled/visibility.h>
00032
00033 namespace drizzled {
00034
00035
00036 #define SC_MAXWIDTH 256
00037 #define ERRMSGSIZE (SC_MAXWIDTH)
00038 #define MY_FILE_ERROR ((size_t) -1)
00039 #define ME_FATALERROR 1024
00040
00041
00042
00043
00044 class ErrorMap : boost::noncopyable
00045 {
00046 public:
00047 typedef std::pair<std::string, std::string> value_type;
00048 typedef boost::unordered_map<error_t, value_type> ErrorMessageMap;
00049
00050 ErrorMap();
00051
00052
00053
00054 void add(error_t error_num, const std::string &error_name, const std::string &message);
00055
00056 const std::string* find(error_t error_num) const;
00057
00058 static const ErrorMessageMap& get_error_message_map();
00059 private:
00060 ErrorMessageMap mapping_;
00061 };
00062
00063 typedef void (*error_handler_func)(error_t my_err,
00064 const char *str,
00065 myf MyFlags);
00066 extern error_handler_func error_handler_hook;
00067
00068
00069
00070 DRIZZLED_API const char * error_message(error_t err_index);
00071
00072
00073 void add_error_message(error_t error_code, const std::string &error_name,
00074 const std::string& message);
00075 #define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
00076
00077 namespace error {
00078
00079 void access(const identifier::User&);
00080 void access(const identifier::User&, const identifier::Schema&);
00081 void access(const identifier::User&, const identifier::Table&);
00082
00083 const std::string &verbose_string();
00084 error::priority_t &verbosity();
00085 void check_verbosity(const std::string &arg);
00086
00087 }
00088
00089
00090 DRIZZLED_API void my_error(const std::string &ref, error_t nr, myf MyFlags= MYF(0));
00091 DRIZZLED_API void my_error(error_t nr, const Identifier&, myf MyFlags= MYF(0));
00092 DRIZZLED_API void my_error(error_t nr);
00093 DRIZZLED_API void my_error(error_t nr, myf MyFlags, ...);
00094 void my_message(error_t my_err, const char *str, myf MyFlags);
00095 void my_printf_error(error_t my_err, const char *format,
00096 myf MyFlags, ...)
00097 __attribute__((format(printf, 2, 4)));
00098
00099 }
00100