~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
2187.2.3 by Brian Aker
This cleans up the the error message system by providing for the ability to
27
#include <drizzled/definitions.h>
28
#include <drizzled/error/level_t.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
29
#include <drizzled/error_t.h>
30
#include <drizzled/identifier.h>
31
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
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 MY_FILE_ERROR	((size_t) -1)
40
#define ME_FATALERROR   1024    /* Fatal statement error */
41
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
42
/*
43
 * Provides a mapping from the error enum values to std::strings.
44
 */
45
class ErrorMap
46
{
47
public:
48
  typedef std::pair<std::string, std::string> value_type;
2087.3.1 by Brian Aker
Entire convert over to time_t.
49
  typedef boost::unordered_map<drizzled::error_t, value_type> ErrorMessageMap;
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
50
51
  ErrorMap();
52
53
  // Insert the message for the error.  If the error already has an existing
54
  // mapping, an error is logged, but the function continues.
2087.3.1 by Brian Aker
Entire convert over to time_t.
55
  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.
56
57
  // 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.
58
  const std::string &find(drizzled::error_t error_num) const;
1996.3.2 by Monty Taylor
Add API for getting at ErrorMap information.
59
60
  static const ErrorMessageMap& get_error_message_map();
61
private:
62
  // Disable copy and assignment.
63
  ErrorMap(const ErrorMap &e);
64
  ErrorMap& operator=(const ErrorMap &e);
65
66
  ErrorMessageMap mapping_;
67
};
68
2087.3.1 by Brian Aker
Entire convert over to time_t.
69
typedef void (*error_handler_func)(drizzled::error_t my_err,
1271.5.7 by Monty Taylor
Merged up with trunk.
70
                                   const char *str,
71
                                   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.
72
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.
73
1271.7.9 by Tim Penhey
Almost there.
74
// TODO: kill this method. Too much to do with this branch.
75
// 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
76
DRIZZLED_API const char * error_message(drizzled::error_t err_index);
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
77
1271.7.9 by Tim Penhey
Almost there.
78
// Adds the message to the global error dictionary.
2087.3.1 by Brian Aker
Entire convert over to time_t.
79
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.
80
                       const std::string& message);
81
#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.
82
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
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
2187.2.3 by Brian Aker
This cleans up the the error message system by providing for the ability to
89
const std::string &verbose_string();
90
error::level_t &verbosity();
91
void check_verbosity(const std::string &arg);
92
2159.2.8 by Brian Aker
Merge in fixes for error messages with privs.
93
} // namespace error
94
95
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
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, ...);
2087.3.1 by Brian Aker
Entire convert over to time_t.
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,
1271.5.1 by Tim Penhey
Move the bits from my_error.h and my_error.cc into error.h and error.cc.
102
                     myf MyFlags, ...)
103
                     __attribute__((format(printf, 2, 4)));
104
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
105
} /* namespace drizzled */
1271.7.4 by Tim Penhey
Another incremental commit.
106
1122.2.10 by Monty Taylor
Fixed all of the include guards.
107
#endif /* DRIZZLED_ERROR_H */