~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.h

  • Committer: Brian Aker
  • Date: 2011-01-12 06:45:23 UTC
  • mto: (2073.1.4 catalogs)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: brian@tangent.org-20110112064523-rqhptaqbph22qmj1
RemoveĀ customĀ error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
 
21
20
#ifndef DRIZZLED_ERROR_H
22
21
#define DRIZZLED_ERROR_H
23
22
 
24
23
#include <string>
25
24
#include <boost/unordered_map.hpp>
26
25
 
27
 
#include <drizzled/definitions.h>
28
 
#include <drizzled/error/level_t.h>
29
 
#include <drizzled/error_t.h>
30
 
#include <drizzled/identifier.h>
31
 
#include <drizzled/visibility.h>
 
26
#include "drizzled/error_t.h"
 
27
#include "drizzled/definitions.h"
 
28
#include "drizzled/identifier.h"
32
29
 
33
30
namespace drizzled
34
31
{
36
33
/* Max width of screen (for error messages) */
37
34
#define SC_MAXWIDTH 256
38
35
#define ERRMSGSIZE      (SC_MAXWIDTH)   /* Max length of a error message */
 
36
#define NRERRBUFFS      (2)     /* Buffers for parameters */
39
37
#define MY_FILE_ERROR   ((size_t) -1)
40
38
#define ME_FATALERROR   1024    /* Fatal statement error */
41
39
 
46
44
{
47
45
public:
48
46
  typedef std::pair<std::string, std::string> value_type;
49
 
  typedef boost::unordered_map<drizzled::error_t, value_type> ErrorMessageMap;
 
47
  typedef boost::unordered_map<uint32_t, value_type> ErrorMessageMap;
50
48
 
51
49
  ErrorMap();
52
50
 
53
51
  // Insert the message for the error.  If the error already has an existing
54
52
  // 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);
 
53
  void add(uint32_t error_num, const std::string &error_name, const std::string &message);
56
54
 
57
55
  // 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(uint32_t error_num) const;
59
57
 
60
58
  static const ErrorMessageMap& get_error_message_map();
61
59
private:
66
64
  ErrorMessageMap mapping_;
67
65
};
68
66
 
69
 
typedef void (*error_handler_func)(drizzled::error_t my_err,
 
67
 
 
68
typedef void (*error_handler_func)(uint32_t my_err,
70
69
                                   const char *str,
71
70
                                   myf MyFlags);
72
71
extern error_handler_func error_handler_hook;
73
72
 
74
73
// TODO: kill this method. Too much to do with this branch.
75
74
// This is called through the ER(x) macro.
76
 
DRIZZLED_API const char * error_message(drizzled::error_t err_index);
 
75
const char * error_message(unsigned int err_index);
77
76
 
78
77
// Adds the message to the global error dictionary.
79
 
void add_error_message(drizzled::error_t error_code, const std::string &error_name,
 
78
void add_error_message(uint32_t error_code, const std::string &error_name,
80
79
                       const std::string& message);
81
80
#define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
82
81
 
83
 
namespace error {
84
 
 
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);
88
 
 
89
 
const std::string &verbose_string();
90
 
error::level_t &verbosity();
91
 
void check_verbosity(const std::string &arg);
92
 
 
93
 
} // namespace error
94
 
 
95
 
 
96
 
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));
98
 
DRIZZLED_API void my_error(error_t nr);
99
 
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,
 
82
void my_error(error_t nr, drizzled::Identifier::const_reference ref);
 
83
void my_error(error_t nr);
 
84
void my_error(error_t nr, myf MyFlags, ...);
 
85
void my_message(uint32_t my_err, const char *str, myf MyFlags);
 
86
void my_printf_error(uint32_t my_err, const char *format,
102
87
                     myf MyFlags, ...)
103
88
                     __attribute__((format(printf, 2, 4)));
104
89