~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.h

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
mergeĀ lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

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