~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.h

  • Committer: Brian Aker
  • Date: 2010-09-12 01:42:27 UTC
  • mto: (1759.2.1 build)
  • mto: This revision was merged to the branch mainline in revision 1762.
  • Revision ID: brian@tangent.org-20100912014227-krt6d9z5ohqrokhb
Add two plugins to handle the string and math functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#define DRIZZLED_ERROR_H
22
22
 
23
23
#include <string>
24
 
#include <boost/unordered_map.hpp>
25
 
 
26
24
#include "drizzled/definitions.h"
27
25
 
28
26
namespace drizzled
35
33
#define MY_FILE_ERROR   ((size_t) -1)
36
34
#define ME_FATALERROR   1024    /* Fatal statement error */
37
35
 
38
 
/*
39
 
 * Provides a mapping from the error enum values to std::strings.
40
 
 */
41
 
class ErrorMap
42
 
{
43
 
public:
44
 
  typedef std::pair<std::string, std::string> value_type;
45
 
  typedef boost::unordered_map<uint32_t, value_type> ErrorMessageMap;
46
 
 
47
 
  ErrorMap();
48
 
 
49
 
  // Insert the message for the error.  If the error already has an existing
50
 
  // mapping, an error is logged, but the function continues.
51
 
  void add(uint32_t error_num, const std::string &error_name, const std::string &message);
52
 
 
53
 
  // If there is no error mapping for the error_num, ErrorStringNotFound is raised.
54
 
  const std::string &find(uint32_t error_num) const;
55
 
 
56
 
  static const ErrorMessageMap& get_error_message_map();
57
 
private:
58
 
  // Disable copy and assignment.
59
 
  ErrorMap(const ErrorMap &e);
60
 
  ErrorMap& operator=(const ErrorMap &e);
61
 
 
62
 
  ErrorMessageMap mapping_;
63
 
};
64
 
 
65
 
 
66
36
typedef void (*error_handler_func)(uint32_t my_err,
67
37
                                   const char *str,
68
38
                                   myf MyFlags);
73
43
const char * error_message(unsigned int err_index);
74
44
 
75
45
// Adds the message to the global error dictionary.
76
 
void add_error_message(uint32_t error_code, const std::string &error_name,
77
 
                       const std::string& message);
78
 
#define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
 
46
void add_error_message(uint32_t error_code, std::string const& message);
79
47
 
80
48
void my_error(int nr, myf MyFlags, ...);
81
49
void my_message(uint32_t my_err, const char *str, myf MyFlags);