~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.cc

  • Committer: Brian Aker
  • Date: 2011-01-25 07:22:15 UTC
  • mfrom: (2109.1.7 drizzle-build)
  • Revision ID: brian@tangent.org-20110125072215-567z6uzy5vdvn4va
Merge in build/timestamp patches/fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2000 MySQL AB
5
 
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *  Copyright (C) 2008 Sun Microsystems, Inc.
6
6
 *
7
7
 *  This program is free software; you can redistribute it and/or modify
8
8
 *  it under the terms of the GNU General Public License as published by
28
28
#include "drizzled/error.h"
29
29
#include "drizzled/gettext.h"
30
30
 
 
31
#include "drizzled/identifier.h"
 
32
 
31
33
#include <boost/unordered_map.hpp>
32
34
#include <exception>
33
35
 
56
58
  return get_error_map().mapping_;
57
59
}
58
60
 
59
 
void add_error_message(uint32_t error_code,
 
61
void add_error_message(drizzled::error_t error_code,
60
62
                       const std::string &error_name,
61
63
                       const std::string &message)
62
64
{
63
65
  get_error_map().add(error_code, error_name, message);
64
66
}
65
67
 
66
 
const char * error_message(unsigned int code)
 
68
const char * error_message(drizzled::error_t code)
67
69
{
68
70
  try
69
71
  {
96
98
       ...      variable list
97
99
*/
98
100
 
99
 
void my_error(int nr, myf MyFlags, ...)
 
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, ...)
100
119
{
101
120
  std::string format;
102
121
  va_list args;
127
146
      ...       variable list
128
147
*/
129
148
 
130
 
void my_printf_error(uint32_t error, const char *format, myf MyFlags, ...)
 
149
void my_printf_error(drizzled::error_t error, const char *format, myf MyFlags, ...)
131
150
{
132
151
  va_list args;
133
152
  char ebuff[ERRMSGSIZE+20];
136
155
  (void) vsnprintf (ebuff, sizeof(ebuff), format, args);
137
156
  va_end(args);
138
157
  (*error_handler_hook)(error, ebuff, MyFlags);
139
 
  return;
140
158
}
141
159
 
142
160
/*
149
167
      MyFlags   Flags
150
168
*/
151
169
 
152
 
void my_message(uint32_t error, const char *str, register myf MyFlags)
 
170
void my_message(drizzled::error_t error, const char *str, register myf MyFlags)
153
171
{
154
172
  (*error_handler_hook)(error, str, MyFlags);
155
173
}
157
175
 
158
176
// Insert the message for the error.  If the error already has an existing
159
177
// mapping, an error is logged, but the function continues.
160
 
void ErrorMap::add(uint32_t error_num,
 
178
void ErrorMap::add(drizzled::error_t error_num,
161
179
                   const std::string &error_name,
162
180
                   const std::string &message)
163
181
{
172
190
  }
173
191
}
174
192
 
175
 
const std::string &ErrorMap::find(uint32_t error_num) const
 
193
const std::string &ErrorMap::find(drizzled::error_t error_num) const
176
194
{
177
195
  ErrorMessageMap::const_iterator pos= mapping_.find(error_num);
178
196
  if (pos == mapping_.end())
186
204
// Constructor sets the default mappings.
187
205
ErrorMap::ErrorMap()
188
206
{
 
207
  ADD_ERROR_MESSAGE(EE_OK, N_("SUCCESS"));
 
208
  ADD_ERROR_MESSAGE(EE_ERROR_FIRST, N_("Error on first"));
189
209
  ADD_ERROR_MESSAGE(ER_NO, N_("NO"));
190
210
  ADD_ERROR_MESSAGE(ER_YES, N_("YES"));
191
211
  ADD_ERROR_MESSAGE(ER_CANT_CREATE_FILE, N_("Can't create file '%-.200s' (errno: %d)"));
454
474
  ADD_ERROR_MESSAGE(ER_LOAD_DATA_INVALID_COLUMN, N_("Invalid column reference (%-.64s) in LOAD DATA"));
455
475
  ADD_ERROR_MESSAGE(ER_INVALID_UNIX_TIMESTAMP_VALUE, N_("Received an invalid value '%s' for a UNIX timestamp."));
456
476
  ADD_ERROR_MESSAGE(ER_INVALID_DATETIME_VALUE, N_("Received an invalid datetime value '%s'."));
 
477
  ADD_ERROR_MESSAGE(ER_INVALID_TIMESTAMP_VALUE, N_("Received an invalid timestamp value '%s'."));
457
478
  ADD_ERROR_MESSAGE(ER_INVALID_NULL_ARGUMENT, N_("Received a NULL argument for function '%s'."));
458
479
  ADD_ERROR_MESSAGE(ER_ARGUMENT_OUT_OF_RANGE, N_("Received an out-of-range argument '%s' for function '%s'."));
459
480
  ADD_ERROR_MESSAGE(ER_INVALID_ENUM_VALUE, N_("Received an invalid enum value '%s'."));
460
481
  ADD_ERROR_MESSAGE(ER_NO_PRIMARY_KEY_ON_REPLICATED_TABLE, N_("Tables which are replicated require a primary key."));
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"));
 
482
 
 
483
  ADD_ERROR_MESSAGE(ER_CORRUPT_SCHEMA_DEFINITION, N_("Corrupt or invalid schema definition for '%s' : %s"));
 
484
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION, N_("Corrupt or invalid table definition for '%s': %s"));
 
485
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION_ENUM, N_("The number of enum that were required was too high for table '%s'"));
 
486
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN, N_("Corrupt or invalid table definition for '%s'"));
 
487
  ADD_ERROR_MESSAGE(ER_CORRUPT_TABLE_DEFINITION_UNKNOWN_COLLATION, N_("Collation '%s' for table %s is invalid/unknown"));
 
488
 
 
489
  ADD_ERROR_MESSAGE(ER_TABLE_DROP, N_("Cannot drop table '%s'"));
 
490
  ADD_ERROR_MESSAGE(ER_TABLE_DROP_ERROR_OCCURRED, N_("Error occurred while dropping table '%s'"));
 
491
  ADD_ERROR_MESSAGE(ER_TABLE_PERMISSION_DENIED, N_("Permission denied to create '%s'"));
 
492
  ADD_ERROR_MESSAGE(ER_TABLE_UNKNOWN, N_("Unknown table '%s'"));
 
493
 
463
494
  ADD_ERROR_MESSAGE(ER_SCHEMA_DOES_NOT_EXIST, N_("Schema does not exist: %s"));
464
495
  ADD_ERROR_MESSAGE(ER_ALTER_SCHEMA, N_("Error altering schema: %s"));
465
496
  ADD_ERROR_MESSAGE(ER_DROP_SCHEMA, +N_("Error droppping Schema : %s"));
481
512
 
482
513
  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"));
483
514
 
 
515
  // Cast errors
 
516
  ADD_ERROR_MESSAGE(ER_INVALID_CAST_TO_UNSIGNED, N_("Cast to unsigned converted negative integer to it's positive complement: %s"));
 
517
  ADD_ERROR_MESSAGE(ER_INVALID_CAST_TO_SIGNED, N_("Invalid cast to signed integer: %s"));
 
518
 
 
519
  ADD_ERROR_MESSAGE(ER_SQL_KEYWORD, N_("Identifier '%.*s' is a SQL keyword."));
 
520
 
484
521
 
485
522
  ADD_ERROR_MESSAGE(EE_CANTUNLOCK, N_("Can't unlock file (Errcode: %d)"));
486
523
  ADD_ERROR_MESSAGE(EE_CANT_CHSIZE, N_("Can't change size of file (Errcode: %d)"));
501
538
  ADD_ERROR_MESSAGE(ER_INVALID_UUID_VALUE, N_("Received an invalid UUID value"));
502
539
  ADD_ERROR_MESSAGE(ER_INVALID_UUID_TIME, N_("The UUID was not created with a valid time"));
503
540
 
 
541
  // For BOOL type
 
542
  ADD_ERROR_MESSAGE(ER_INVALID_BOOLEAN_VALUE, N_("Received an invalid BOOLEAN value '%s'."));
 
543
  ADD_ERROR_MESSAGE(ER_INVALID_CAST_TO_BOOLEAN, N_("Invalid cast to BOOLEAN: '%s'."));
 
544
 
 
545
  // Transactional DDL
 
546
  ADD_ERROR_MESSAGE(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, N_("Transactional DDL not supported"));
 
547
  // ASSERT Message
 
548
  ADD_ERROR_MESSAGE(ER_ASSERT, N_("Assertion '%s' failed."));
 
549
  ADD_ERROR_MESSAGE(ER_ASSERT_NULL, N_("Assertion '%s' failed, the result was NULL."));
 
550
 
504
551
  // Some old error values use the same strings as some new error values.
505
552
  ADD_ERROR_MESSAGE(EE_FILENOTFOUND, find(ER_FILE_NOT_FOUND));
506
553
  ADD_ERROR_MESSAGE(EE_CANTCREATEFILE, find(ER_CANT_CREATE_FILE));
515
562
  ADD_ERROR_MESSAGE(EE_DIR, find(ER_CANT_READ_DIR));
516
563
  ADD_ERROR_MESSAGE(EE_STAT, find(ER_CANT_GET_STAT));
517
564
  ADD_ERROR_MESSAGE(EE_DISK_FULL, find(ER_DISK_FULL));
 
565
  
 
566
  // Catalog related errors
 
567
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_CREATE, N_("Cannot create catalog '%s'."));
 
568
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_CREATE_PERMISSION, N_("Permission is denied to create '%s' catalog."));
 
569
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_DROP, N_("Cannot drop catalog '%s'."));
 
570
  ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_DROP_PERMISSION, N_("Permission is denied to drop '%s' catalog."));
 
571
  ADD_ERROR_MESSAGE(ER_CATALOG_DOES_NOT_EXIST, N_("Catalog '%s' does not exist."));
 
572
  ADD_ERROR_MESSAGE(ER_CATALOG_NO_DROP_LOCAL, N_("You cannot drop the 'local' catalog."));
 
573
  ADD_ERROR_MESSAGE(ER_CATALOG_NO_LOCK, N_("Could not gain lock on '%s'."));
 
574
  ADD_ERROR_MESSAGE(ER_CORRUPT_CATALOG_DEFINITION, N_("Corrupt or invalid catalog definition for '%s' : '%s'."));
 
575
  ADD_ERROR_MESSAGE(ER_WRONG_NAME_FOR_CATALOG, N_("Invalid catalog name."));
 
576
 
518
577
 
519
578
}
520
579