~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.cc

  • Committer: Brian Aker
  • Date: 2010-12-19 06:20:54 UTC
  • mfrom: (2005.1.1 bug673105)
  • Revision ID: brian@tangent.org-20101219062054-1kt0l3dxs4z2z8md
Merge Dave.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "drizzled/error.h"
29
29
#include "drizzled/gettext.h"
30
30
 
31
 
#include "drizzled/identifier.h"
32
 
 
33
31
#include <boost/unordered_map.hpp>
34
32
#include <exception>
35
33
 
58
56
  return get_error_map().mapping_;
59
57
}
60
58
 
61
 
void add_error_message(drizzled::error_t error_code,
 
59
void add_error_message(uint32_t error_code,
62
60
                       const std::string &error_name,
63
61
                       const std::string &message)
64
62
{
65
63
  get_error_map().add(error_code, error_name, message);
66
64
}
67
65
 
68
 
const char * error_message(drizzled::error_t code)
 
66
const char * error_message(unsigned int code)
69
67
{
70
68
  try
71
69
  {
98
96
       ...      variable list
99
97
*/
100
98
 
101
 
void my_error(const std::string &ref, error_t nr, myf MyFlags)
102
 
{
103
 
  my_error(nr, MyFlags, ref.c_str());
104
 
105
 
 
106
 
void my_error(error_t nr, drizzled::Identifier::const_reference ref, myf MyFlags)
107
 
{
108
 
  std::string temp;
109
 
  ref.getSQLPath(temp);
110
 
  my_error(nr, MyFlags, temp.c_str());
111
 
112
 
 
113
 
void my_error(error_t nr)
114
 
{
115
 
  my_error(nr, MYF(0));
116
 
}
117
 
 
118
 
void my_error(error_t nr, myf MyFlags, ...)
 
99
void my_error(int nr, myf MyFlags, ...)
119
100
{
120
101
  std::string format;
121
102
  va_list args;
146
127
      ...       variable list
147
128
*/
148
129
 
149
 
void my_printf_error(drizzled::error_t error, const char *format, myf MyFlags, ...)
 
130
void my_printf_error(uint32_t error, const char *format, myf MyFlags, ...)
150
131
{
151
132
  va_list args;
152
133
  char ebuff[ERRMSGSIZE+20];
155
136
  (void) vsnprintf (ebuff, sizeof(ebuff), format, args);
156
137
  va_end(args);
157
138
  (*error_handler_hook)(error, ebuff, MyFlags);
 
139
  return;
158
140
}
159
141
 
160
142
/*
167
149
      MyFlags   Flags
168
150
*/
169
151
 
170
 
void my_message(drizzled::error_t error, const char *str, register myf MyFlags)
 
152
void my_message(uint32_t error, const char *str, register myf MyFlags)
171
153
{
172
154
  (*error_handler_hook)(error, str, MyFlags);
173
155
}
175
157
 
176
158
// Insert the message for the error.  If the error already has an existing
177
159
// mapping, an error is logged, but the function continues.
178
 
void ErrorMap::add(drizzled::error_t error_num,
 
160
void ErrorMap::add(uint32_t error_num,
179
161
                   const std::string &error_name,
180
162
                   const std::string &message)
181
163
{
190
172
  }
191
173
}
192
174
 
193
 
const std::string &ErrorMap::find(drizzled::error_t error_num) const
 
175
const std::string &ErrorMap::find(uint32_t error_num) const
194
176
{
195
177
  ErrorMessageMap::const_iterator pos= mapping_.find(error_num);
196
178
  if (pos == mapping_.end())
204
186
// Constructor sets the default mappings.
205
187
ErrorMap::ErrorMap()
206
188
{
207
 
  ADD_ERROR_MESSAGE(EE_OK, N_("SUCCESS"));
208
 
  ADD_ERROR_MESSAGE(EE_ERROR_FIRST, N_("Error on first"));
209
189
  ADD_ERROR_MESSAGE(ER_NO, N_("NO"));
210
190
  ADD_ERROR_MESSAGE(ER_YES, N_("YES"));
211
191
  ADD_ERROR_MESSAGE(ER_CANT_CREATE_FILE, N_("Can't create file '%-.200s' (errno: %d)"));
267
247
  ADD_ERROR_MESSAGE(ER_DUP_ENTRY, N_("Duplicate entry '%-.192s' for key %d"));
268
248
  ADD_ERROR_MESSAGE(ER_WRONG_FIELD_SPEC, N_("Incorrect column specifier for column '%-.192s'"));
269
249
  ADD_ERROR_MESSAGE(ER_PARSE_ERROR, N_("%s near '%-.80s' at line %d"));
270
 
  ADD_ERROR_MESSAGE(ER_PARSE_ERROR_UNKNOWN, N_("Parsing error near '%s'"));
271
250
  ADD_ERROR_MESSAGE(ER_EMPTY_QUERY, N_("Query was empty"));
272
251
  ADD_ERROR_MESSAGE(ER_NONUNIQ_TABLE, N_("Not unique table/alias: '%-.192s'"));
273
252
  ADD_ERROR_MESSAGE(ER_INVALID_DEFAULT, N_("Invalid default value for '%-.192s'"));
323
302
  ADD_ERROR_MESSAGE(ER_NULL_COLUMN_IN_INDEX, N_("Table handler doesn't support NULL in given index. Please change column '%-.192s' to be NOT NULL or use another handler"));
324
303
  ADD_ERROR_MESSAGE(ER_PLUGIN_NO_PATHS, N_("No paths allowed for plugin library"));
325
304
  ADD_ERROR_MESSAGE(ER_PLUGIN_EXISTS, N_("Plugin '%-.192s' already exists"));
326
 
  ADD_ERROR_MESSAGE(ER_CANT_OPEN_LIBRARY, N_("Can't open shared library '%-.192s' (errno: %d %s)"));
327
 
  ADD_ERROR_MESSAGE(ER_CANT_FIND_DL_ENTRY, N_("Can't find symbol '%-.128s' in library '%s'"));
 
305
  ADD_ERROR_MESSAGE(ER_CANT_OPEN_LIBRARY, N_("Can't open shared library '%-.192s' (errno: %d %-.128s)"));
 
306
  ADD_ERROR_MESSAGE(ER_CANT_FIND_DL_ENTRY, N_("Can't find symbol '%-.128s' in library '%-.128s'"));
328
307
  ADD_ERROR_MESSAGE(ER_UPDATE_INFO, N_("Rows matched: %ld  Changed: %ld  Warnings: %ld"));
329
308
  ADD_ERROR_MESSAGE(ER_CANT_CREATE_THREAD, N_("Can't create a new thread (errno %d); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug"));
330
309
  ADD_ERROR_MESSAGE(ER_WRONG_VALUE_COUNT_ON_ROW, N_("Column count doesn't match value count at row %ld"));
331
310
  ADD_ERROR_MESSAGE(ER_CANT_REOPEN_TABLE, N_("Can't reopen table: '%-.192s'"));
332
311
  ADD_ERROR_MESSAGE(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, N_("Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause"));
 
312
  ADD_ERROR_MESSAGE(ER_NO_SUCH_TABLE, N_("Table '%-.192s.%-.192s' doesn't exist"));
333
313
  ADD_ERROR_MESSAGE(ER_SYNTAX_ERROR, N_("You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use"));
334
314
  ADD_ERROR_MESSAGE(ER_NET_PACKET_TOO_LARGE, N_("Got a packet bigger than 'max_allowed_packet' bytes"));
335
315
  ADD_ERROR_MESSAGE(ER_NET_PACKETS_OUT_OF_ORDER, N_("Got packets out of order"));
472
452
  ADD_ERROR_MESSAGE(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, N_("Incorrect parameters in the call to native function '%-.192s'"));
473
453
  ADD_ERROR_MESSAGE(ER_DUP_ENTRY_WITH_KEY_NAME, N_("Duplicate entry '%-.64s' for key '%-.192s'"));
474
454
  ADD_ERROR_MESSAGE(ER_LOAD_DATA_INVALID_COLUMN, N_("Invalid column reference (%-.64s) in LOAD DATA"));
475
 
 
 
455
  ADD_ERROR_MESSAGE(ER_INVALID_UNIX_TIMESTAMP_VALUE, N_("Received an invalid value '%s' for a UNIX timestamp."));
476
456
  ADD_ERROR_MESSAGE(ER_INVALID_DATETIME_VALUE, N_("Received an invalid datetime value '%s'."));
477
 
  ADD_ERROR_MESSAGE(ER_INVALID_DATE_VALUE, N_("Received an invalid DATE value '%s'."));
478
457
  ADD_ERROR_MESSAGE(ER_INVALID_NULL_ARGUMENT, N_("Received a NULL argument for function '%s'."));
479
 
  ADD_ERROR_MESSAGE(ER_INVALID_TIMESTAMP_VALUE, N_("Received an invalid timestamp value '%s'."));
480
 
  ADD_ERROR_MESSAGE(ER_INVALID_TIME_VALUE, N_("Received an invalid TIME value '%s'."));
481
 
  ADD_ERROR_MESSAGE(ER_INVALID_UNIX_TIMESTAMP_VALUE, N_("Received an invalid value '%s' for a UNIX timestamp."));
482
 
 
483
458
  ADD_ERROR_MESSAGE(ER_ARGUMENT_OUT_OF_RANGE, N_("Received an out-of-range argument '%s' for function '%s'."));
484
459
  ADD_ERROR_MESSAGE(ER_INVALID_ENUM_VALUE, N_("Received an invalid enum value '%s'."));
485
460
  ADD_ERROR_MESSAGE(ER_NO_PRIMARY_KEY_ON_REPLICATED_TABLE, N_("Tables which are replicated require a primary key."));
486
 
 
487
 
  ADD_ERROR_MESSAGE(ER_CORRUPT_SCHEMA_DEFINITION, N_("Corrupt or invalid schema definition for '%s' : %s"));
488
 
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION, N_("Corrupt or invalid table definition for '%s': %s"));
489
 
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION_ENUM, N_("The number of enum that were required was too high for table '%s'"));
490
 
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN, N_("Corrupt or invalid table definition for '%s'"));
491
 
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN_COLLATION, N_("Collation '%s' for table %s is invalid/unknown"));
492
 
 
493
 
  ADD_ERROR_MESSAGE(ER_TABLE_DROP, N_("Cannot drop table '%s'"));
494
 
  ADD_ERROR_MESSAGE(ER_TABLE_DROP_ERROR_OCCURRED, N_("Error occurred while dropping table '%s'"));
495
 
  ADD_ERROR_MESSAGE(ER_TABLE_PERMISSION_DENIED, N_("Permission denied to create '%s'"));
496
 
  ADD_ERROR_MESSAGE(ER_TABLE_UNKNOWN, N_("Unknown table '%s'"));
497
 
 
498
 
  ADD_ERROR_MESSAGE(ER_SCHEMA_CANNOT_CREATE, N_("Cannot create schema '%s'"));
 
461
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION, N_("Corrupt or invalid table definition: %s"));
 
462
  ADD_ERROR_MESSAGE(ER_CORRUPT_SCHEMA_DEFINITION, N_("Corrupt or invalid schema definition for %s : %s"));
499
463
  ADD_ERROR_MESSAGE(ER_SCHEMA_DOES_NOT_EXIST, N_("Schema does not exist: %s"));
500
464
  ADD_ERROR_MESSAGE(ER_ALTER_SCHEMA, N_("Error altering schema: %s"));
501
465
  ADD_ERROR_MESSAGE(ER_DROP_SCHEMA, +N_("Error droppping Schema : %s"));
502
 
 
503
466
  ADD_ERROR_MESSAGE(ER_USE_SQL_BIG_RESULT, N_("Temporary table too large, rerun with SQL_BIG_RESULT."));
504
467
  ADD_ERROR_MESSAGE(ER_UNKNOWN_ENGINE_OPTION, N_("Unknown table engine option key/pair %s = %s."));
505
468
  ADD_ERROR_MESSAGE(ER_UNKNOWN_SCHEMA_OPTION, N_("Unknown schema engine option key/pair %s = %s."));
506
 
  ADD_ERROR_MESSAGE(ER_CARTESIAN_JOIN_ATTEMPTED, N_("Implicit cartesian join attempted."));
 
469
 
507
470
  ADD_ERROR_MESSAGE(ER_ADMIN_ACCESS, N_("Admin access not allowed from this username/IP address."));
508
471
 
509
472
  // User lock/barrier error messages
518
481
 
519
482
  ADD_ERROR_MESSAGE(ER_INVALID_ALTER_TABLE_FOR_NOT_NULL, N_("Either a DEFAULt value or NULL NULL description is required for a new column if table is not empty"));
520
483
 
521
 
  // Cast errors
522
 
  ADD_ERROR_MESSAGE(ER_INVALID_CAST_TO_UNSIGNED, N_("Cast to unsigned converted negative integer to it's positive complement: %s"));
523
 
  ADD_ERROR_MESSAGE(ER_INVALID_CAST_TO_SIGNED, N_("Invalid cast to signed integer: %s"));
524
 
 
525
 
  ADD_ERROR_MESSAGE(ER_SQL_KEYWORD, N_("Identifier '%.*s' is a SQL keyword."));
526
 
 
527
484
 
528
485
  ADD_ERROR_MESSAGE(EE_CANTUNLOCK, N_("Can't unlock file (Errcode: %d)"));
529
486
  ADD_ERROR_MESSAGE(EE_CANT_CHSIZE, N_("Can't change size of file (Errcode: %d)"));
544
501
  ADD_ERROR_MESSAGE(ER_INVALID_UUID_VALUE, N_("Received an invalid UUID value"));
545
502
  ADD_ERROR_MESSAGE(ER_INVALID_UUID_TIME, N_("The UUID was not created with a valid time"));
546
503
 
547
 
  // For BOOL type
548
 
  ADD_ERROR_MESSAGE(ER_INVALID_BOOLEAN_VALUE, N_("Received an invalid BOOLEAN value '%s'."));
549
 
  ADD_ERROR_MESSAGE(ER_INVALID_CAST_TO_BOOLEAN, N_("Invalid cast to BOOLEAN: '%s'."));
550
 
 
551
 
  // Transactional DDL
552
 
  ADD_ERROR_MESSAGE(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, N_("Transactional DDL not supported"));
553
 
  // ASSERT Message
554
 
  ADD_ERROR_MESSAGE(ER_ASSERT, N_("Assertion '%s' failed."));
555
 
  ADD_ERROR_MESSAGE(ER_ASSERT_NULL, N_("Assertion '%s' failed, the result was NULL."));
556
 
 
557
504
  // Some old error values use the same strings as some new error values.
558
505
  ADD_ERROR_MESSAGE(EE_FILENOTFOUND, find(ER_FILE_NOT_FOUND));
559
506
  ADD_ERROR_MESSAGE(EE_CANTCREATEFILE, find(ER_CANT_CREATE_FILE));
568
515
  ADD_ERROR_MESSAGE(EE_DIR, find(ER_CANT_READ_DIR));
569
516
  ADD_ERROR_MESSAGE(EE_STAT, find(ER_CANT_GET_STAT));
570
517
  ADD_ERROR_MESSAGE(EE_DISK_FULL, find(ER_DISK_FULL));
571
 
  
572
 
  // Catalog related errors
573
 
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_CREATE, N_("Cannot create catalog '%s'."));
574
 
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_CREATE_PERMISSION, N_("Permission is denied to create '%s' catalog."));
575
 
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_DROP, N_("Cannot drop catalog '%s'."));
576
 
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_DROP_PERMISSION, N_("Permission is denied to drop '%s' catalog."));
577
 
  ADD_ERROR_MESSAGE(ER_CATALOG_DOES_NOT_EXIST, N_("Catalog '%s' does not exist."));
578
 
  ADD_ERROR_MESSAGE(ER_CATALOG_NO_DROP_LOCAL, N_("You cannot drop the 'local' catalog."));
579
 
  ADD_ERROR_MESSAGE(ER_CATALOG_NO_LOCK, N_("Could not gain lock on '%s'."));
580
 
  ADD_ERROR_MESSAGE(ER_CORRUPT_CATALOG_DEFINITION, N_("Corrupt or invalid catalog definition for '%s' : '%s'."));
581
 
  ADD_ERROR_MESSAGE(ER_WRONG_NAME_FOR_CATALOG, N_("Invalid catalog name."));
582
 
  ADD_ERROR_MESSAGE(ER_USE_DATA_DICTIONARY, N_("Engine status is now stored in the data_dictionary tables, please use these instead."));
583
 
  ADD_ERROR_MESSAGE(ER_TRANSACTION_ALREADY_STARTED, N_("There is already a transaction in progress"));
584
518
 
585
519
}
586
520