~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
212.5.42 by Monty Taylor
Ding dong include is dead.
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
212.5.42 by Monty Taylor
Ding dong include is dead.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
8
 *  the Free Software Foundation; version 2 of the License.
212.5.42 by Monty Taylor
Ding dong include is dead.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
20
1122.2.10 by Monty Taylor
Fixed all of the include guards.
21
#ifndef DRIZZLED_ERROR_H
22
#define DRIZZLED_ERROR_H
212.5.42 by Monty Taylor
Ding dong include is dead.
23
1271.7.9 by Tim Penhey
Almost there.
24
#include <string>
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
25
#include <boost/unordered_map.hpp>
26
2041.3.16 by Brian Aker
Merge in change so that we pull out the error_t enum out to its own
27
#include "drizzled/error_t.h"
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
28
#include "drizzled/definitions.h"
2041.3.15 by Brian Aker
Cleanup error usage around identifier usage.
29
#include "drizzled/identifier.h"
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
30
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
31
#include "drizzled/visibility.h"
32
1271.6.2 by Tim Penhey
Make sure the bits from my_error.h are inside the drizzled namespace.
33
namespace drizzled
34
{
35
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
36
/* Max width of screen (for error messages) */
37
#define SC_MAXWIDTH 256
38
#define ERRMSGSIZE	(SC_MAXWIDTH)	/* Max length of a error message */
39
#define NRERRBUFFS	(2)	/* Buffers for parameters */
40
#define MY_FILE_ERROR	((size_t) -1)
41
#define ME_FATALERROR   1024    /* Fatal statement error */
42
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
43
/*
44
 * Provides a mapping from the error enum values to std::strings.
45
 */
46
class ErrorMap
47
{
48
public:
49
  typedef std::pair<std::string, std::string> value_type;
2087.3.1 by Brian Aker
Entire convert over to time_t.
50
  typedef boost::unordered_map<drizzled::error_t, value_type> ErrorMessageMap;
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
51
52
  ErrorMap();
53
54
  // Insert the message for the error.  If the error already has an existing
55
  // mapping, an error is logged, but the function continues.
2087.3.1 by Brian Aker
Entire convert over to time_t.
56
  void add(drizzled::error_t error_num, const std::string &error_name, const std::string &message);
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
57
58
  // If there is no error mapping for the error_num, ErrorStringNotFound is raised.
2087.3.1 by Brian Aker
Entire convert over to time_t.
59
  const std::string &find(drizzled::error_t error_num) const;
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
60
61
  static const ErrorMessageMap& get_error_message_map();
62
private:
63
  // Disable copy and assignment.
64
  ErrorMap(const ErrorMap &e);
65
  ErrorMap& operator=(const ErrorMap &e);
66
67
  ErrorMessageMap mapping_;
68
};
69
70
2087.3.1 by Brian Aker
Entire convert over to time_t.
71
typedef void (*error_handler_func)(drizzled::error_t my_err,
1271.5.7 by Monty Taylor
Merged up with trunk.
72
                                   const char *str,
73
                                   myf MyFlags);
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
74
extern error_handler_func error_handler_hook;
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
75
1271.7.9 by Tim Penhey
Almost there.
76
// TODO: kill this method. Too much to do with this branch.
77
// This is called through the ER(x) macro.
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
78
DRIZZLED_API const char * error_message(drizzled::error_t err_index);
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
79
1271.7.9 by Tim Penhey
Almost there.
80
// Adds the message to the global error dictionary.
2087.3.1 by Brian Aker
Entire convert over to time_t.
81
void add_error_message(drizzled::error_t error_code, const std::string &error_name,
1996.3.1 by Monty Taylor
Add error code name into ErrorMap.
82
                       const std::string& message);
83
#define DRIZZLE_ADD_ERROR_MESSAGE(code, msg) add_error_message(code, STRINGIFY_ARG(code), msg)
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
84
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
85
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));
87
DRIZZLED_API void my_error(error_t nr);
88
DRIZZLED_API void my_error(error_t nr, myf MyFlags, ...);
2087.3.1 by Brian Aker
Entire convert over to time_t.
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,
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
91
                     myf MyFlags, ...)
92
                     __attribute__((format(printf, 2, 4)));
93
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
94
} /* namespace drizzled */
1271.7.4 by Tim Penhey
Another incremental commit.
95
1122.2.10 by Monty Taylor
Fixed all of the include guards.
96
#endif /* DRIZZLED_ERROR_H */