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/definitions.h>
00027 #include <drizzled/error/level_t.h>
00028 #include <drizzled/error_t.h>
00029 #include <drizzled/identifier.h>
00030 #include <drizzled/visibility.h>
00031
00032 namespace drizzled
00033 {
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
00045 {
00046 public:
00047 typedef std::pair<std::string, std::string> value_type;
00048 typedef boost::unordered_map<drizzled::error_t, value_type> ErrorMessageMap;
00049
00050 ErrorMap();
00051
00052
00053
00054 void add(drizzled::error_t error_num, const std::string &error_name, const std::string &message);
00055
00056
00057 const std::string &find(drizzled::error_t error_num) const;
00058
00059 static const ErrorMessageMap& get_error_message_map();
00060 private:
00061
00062 ErrorMap(const ErrorMap &e);
00063 ErrorMap& operator=(const ErrorMap &e);
00064
00065 ErrorMessageMap mapping_;
00066 };
00067
00068 typedef void (*error_handler_func)(drizzled::error_t my_err,
00069 const char *str,
00070 myf MyFlags);
00071 extern error_handler_func error_handler_hook;
00072
00073
00074
00075 DRIZZLED_API const char * error_message(drizzled::error_t err_index);
00076
00077
00078 void add_error_message(drizzled::error_t error_code, const std::string &error_name,
00079 const std::string& message);
00080 #define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
00081
00082 namespace error {
00083
00084 void access(drizzled::identifier::User::const_reference user);
00085 void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Schema::const_reference schema);
00086 void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Table::const_reference table);
00087
00088 const std::string &verbose_string();
00089 error::level_t &verbosity();
00090 void check_verbosity(const std::string &arg);
00091
00092 }
00093
00094
00095 DRIZZLED_API void my_error(const std::string &ref, error_t nr, myf MyFlags= MYF(0));
00096 DRIZZLED_API void my_error(error_t nr, drizzled::Identifier::const_reference ref, myf MyFlags= MYF(0));
00097 DRIZZLED_API void my_error(error_t nr);
00098 DRIZZLED_API void my_error(error_t nr, myf MyFlags, ...);
00099 void my_message(drizzled::error_t my_err, const char *str, myf MyFlags);
00100 void my_printf_error(drizzled::error_t my_err, const char *format,
00101 myf MyFlags, ...)
00102 __attribute__((format(printf, 2, 4)));
00103
00104 }
00105