~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/my_error.h

Merged from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
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
8
 
 *  the Free Software Foundation; version 2 of the License.
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
 
 
20
 
#ifndef DRIZZLED_MY_ERROR_H
21
 
#define DRIZZLED_MY_ERROR_H
22
 
 
23
 
#include "drizzled/definitions.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
 
/* Max width of screen (for error messages) */
29
 
#define SC_MAXWIDTH 256
30
 
#define ERRMSGSIZE      (SC_MAXWIDTH)   /* Max length of a error message */
31
 
#define NRERRBUFFS      (2)     /* Buffers for parameters */
32
 
#define MY_FILE_ERROR   ((size_t) -1)
33
 
#define ME_FATALERROR   1024    /* Fatal statement error */
34
 
 
35
 
typedef void (*error_handler_func)(uint32_t my_err, const char *str,myf MyFlags);
36
 
extern error_handler_func error_handler_hook;
37
 
 
38
 
/*
39
 
  Do not add error numbers before EE_ERROR_FIRST.
40
 
  If necessary to add lower numbers, change EE_ERROR_FIRST accordingly.
41
 
 
42
 
  We start with error 1 to not confuse peoples with 'error 0'
43
 
*/
44
 
 
45
 
#define EE_ERROR_FIRST          1 /*Copy first error nr.*/
46
 
#define EE_CANTCREATEFILE       1
47
 
#define EE_READ                 2
48
 
#define EE_WRITE                3
49
 
#define EE_BADCLOSE             4
50
 
#define EE_OUTOFMEMORY          5
51
 
#define EE_DELETE               6
52
 
#define EE_LINK                 7
53
 
#define EE_EOFERR               9
54
 
#define EE_CANTLOCK             10
55
 
#define EE_CANTUNLOCK           11
56
 
#define EE_DIR                  12
57
 
#define EE_STAT                 13
58
 
#define EE_CANT_CHSIZE          14
59
 
#define EE_CANT_OPEN_STREAM     15
60
 
#define EE_GETWD                16
61
 
#define EE_SETWD                17
62
 
#define EE_LINK_WARNING         18
63
 
#define EE_OPEN_WARNING         19
64
 
#define EE_DISK_FULL            20
65
 
#define EE_CANT_MKDIR           21
66
 
#define EE_UNKNOWN_CHARSET      22
67
 
#define EE_OUT_OF_FILERESOURCES 23
68
 
#define EE_CANT_READLINK        24
69
 
#define EE_CANT_SYMLINK         25
70
 
#define EE_REALPATH             26
71
 
#define EE_SYNC                 27
72
 
#define EE_UNKNOWN_COLLATION    28
73
 
#define EE_FILENOTFOUND         29
74
 
#define EE_FILE_NOT_CLOSED      30
75
 
#define EE_ERROR_LAST           30 /* Copy last error nr */
76
 
/* Add error numbers before EE_ERROR_LAST and change it accordingly. */
77
 
 
78
 
  /* exit codes for all MySQL programs */
79
 
 
80
 
#define EXIT_UNSPECIFIED_ERROR          1
81
 
#define EXIT_UNKNOWN_OPTION             2
82
 
#define EXIT_AMBIGUOUS_OPTION           3
83
 
#define EXIT_NO_ARGUMENT_ALLOWED        4
84
 
#define EXIT_ARGUMENT_REQUIRED          5
85
 
#define EXIT_VAR_PREFIX_NOT_UNIQUE      6
86
 
#define EXIT_UNKNOWN_VARIABLE           7
87
 
#define EXIT_OUT_OF_MEMORY              8
88
 
#define EXIT_UNKNOWN_SUFFIX             9
89
 
#define EXIT_NO_PTR_TO_VARIABLE         10
90
 
#define EXIT_CANNOT_CONNECT_TO_SERVICE  11
91
 
#define EXIT_OPTION_DISABLED            12
92
 
#define EXIT_ARGUMENT_INVALID           13
93
 
 
94
 
#define GLOBERRS (EE_ERROR_LAST - EE_ERROR_FIRST + 1) /* Nr of global errors */
95
 
#define EE(X)    (globerrs[(X) - EE_ERROR_FIRST])
96
 
 
97
 
/* Error message numbers in global map */
98
 
extern const char * globerrs[GLOBERRS];
99
 
 
100
 
void init_glob_errs(void);
101
 
void my_error(int nr,myf MyFlags, ...);
102
 
void my_printf_error(uint32_t my_err, const char *format,
103
 
                     myf MyFlags, ...)
104
 
                     __attribute__((format(printf, 2, 4)));
105
 
int my_error_register(const char **errmsgs, int first, int last);
106
 
void my_error_unregister_all(void);
107
 
const char **my_error_unregister(int first, int last);
108
 
void my_message(uint32_t my_err, const char *str,myf MyFlags);
109
 
void my_message_no_curses(uint32_t my_err, const char *str,myf MyFlags);
110
 
 
111
 
} /* namespace drizzled */
112
 
 
113
 
#endif /* DRIZZLED_MY_ERROR_H */
114
 
 
115