53
48
return get_error_map().mapping_;
56
void add_error_message(drizzled::error_t error_code,
51
void add_error_message(error_t error_code,
57
52
const std::string &error_name,
58
53
const std::string &message)
60
55
get_error_map().add(error_code, error_name, message);
63
const char * error_message(drizzled::error_t code)
58
const char* error_message(error_t code)
67
return get_error_map().find(code).c_str();
69
catch (ErrorStringNotFound const&)
71
return get_error_map().find(ER_UNKNOWN_ERROR).c_str();
60
const std::string* ptr = get_error_map().find(code);
61
return ptr ? ptr->c_str() : get_error_map().find(ER_UNKNOWN_ERROR)->c_str();
75
64
error_handler_func error_handler_hook= NULL;
79
68
void access(drizzled::identifier::User::const_reference user)
81
std::string user_string;
82
user.getSQLPath(user_string);
84
my_error(ER_ACCESS_DENIED_ERROR, MYF(0), user_string.c_str(),
85
user.hasPassword() ? ER(ER_YES) : ER(ER_NO));
70
my_error(ER_ACCESS_DENIED_ERROR, MYF(0), user.getSQLPath().c_str(), ER(user.hasPassword() ? ER_YES : ER_NO));
88
73
void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Schema::const_reference schema)
90
std::string user_string;
91
user.getSQLPath(user_string);
93
std::string schema_string;
94
schema.getSQLPath(schema_string);
96
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), user_string.c_str(), schema_string.c_str());
75
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), user.getSQLPath().c_str(), schema.getSQLPath().c_str());
99
78
void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Table::const_reference table)
101
std::string user_string;
102
user.getSQLPath(user_string);
104
std::string table_string;
105
table.getSQLPath(table_string);
107
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), user_string.c_str(), table_string.c_str());
80
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), user.getSQLPath().c_str(), table.getSQLPath().c_str());
110
83
static error::level_t _verbosity= error::ERROR;
190
163
my_error(nr, MyFlags, ref.c_str());
193
void my_error(error_t nr, drizzled::Identifier::const_reference ref, myf MyFlags)
166
void my_error(error_t nr, const drizzled::Identifier& id, myf MyFlags)
196
ref.getSQLPath(temp);
197
my_error(nr, MyFlags, temp.c_str());
168
my_error(nr, MyFlags, id.getSQLPath().c_str());
200
171
void my_error(error_t nr)
205
176
void my_error(error_t nr, myf MyFlags, ...)
209
179
char ebuff[ERRMSGSIZE + 20];
213
format= get_error_map().find(nr);
181
if (const std::string* format= get_error_map().find(nr))
214
183
va_start(args,MyFlags);
215
(void) vsnprintf (ebuff, sizeof(ebuff), _(format.c_str()), args);
184
(void) vsnprintf (ebuff, sizeof(ebuff), _(format->c_str()), args);
218
catch (ErrorStringNotFound const& e)
220
188
(void) snprintf (ebuff, sizeof(ebuff), _("Unknown error %d"), nr);
222
189
(*error_handler_hook)(nr, ebuff, MyFlags);
280
const std::string &ErrorMap::find(drizzled::error_t error_num) const
247
const std::string* ErrorMap::find(drizzled::error_t error_num) const
282
249
const ErrorMessageMap::mapped_type* pos= find_ptr(mapping_, error_num);
285
throw ErrorStringNotFound();
250
return pos ? &pos->second : NULL;
290
253
#define ADD_ERROR_MESSAGE(code, msg) add(code, STRINGIFY_ARG(code), msg)
646
609
ADD_ERROR_MESSAGE(ER_ASSERT_NULL, N_("Assertion '%s' failed, the result was NULL."));
648
611
// Some old error values use the same strings as some new error values.
649
ADD_ERROR_MESSAGE(EE_FILENOTFOUND, find(ER_FILE_NOT_FOUND));
650
ADD_ERROR_MESSAGE(EE_CANTCREATEFILE, find(ER_CANT_CREATE_FILE));
651
ADD_ERROR_MESSAGE(EE_READ, find(ER_ERROR_ON_READ));
652
ADD_ERROR_MESSAGE(EE_WRITE, find(ER_ERROR_ON_WRITE));
653
ADD_ERROR_MESSAGE(EE_BADCLOSE, find(ER_ERROR_ON_CLOSE));
654
ADD_ERROR_MESSAGE(EE_OUTOFMEMORY, find(ER_OUTOFMEMORY));
655
ADD_ERROR_MESSAGE(EE_DELETE, find(ER_CANT_DELETE_FILE));
656
ADD_ERROR_MESSAGE(EE_LINK, find(ER_ERROR_ON_RENAME));
657
ADD_ERROR_MESSAGE(EE_EOFERR, find(ER_UNEXPECTED_EOF));
658
ADD_ERROR_MESSAGE(EE_CANTLOCK, find(ER_CANT_LOCK));
659
ADD_ERROR_MESSAGE(EE_DIR, find(ER_CANT_READ_DIR));
660
ADD_ERROR_MESSAGE(EE_STAT, find(ER_CANT_GET_STAT));
661
ADD_ERROR_MESSAGE(EE_DISK_FULL, find(ER_DISK_FULL));
612
ADD_ERROR_MESSAGE(EE_FILENOTFOUND, *find(ER_FILE_NOT_FOUND));
613
ADD_ERROR_MESSAGE(EE_CANTCREATEFILE, *find(ER_CANT_CREATE_FILE));
614
ADD_ERROR_MESSAGE(EE_READ, *find(ER_ERROR_ON_READ));
615
ADD_ERROR_MESSAGE(EE_WRITE, *find(ER_ERROR_ON_WRITE));
616
ADD_ERROR_MESSAGE(EE_BADCLOSE, *find(ER_ERROR_ON_CLOSE));
617
ADD_ERROR_MESSAGE(EE_OUTOFMEMORY, *find(ER_OUTOFMEMORY));
618
ADD_ERROR_MESSAGE(EE_DELETE, *find(ER_CANT_DELETE_FILE));
619
ADD_ERROR_MESSAGE(EE_LINK, *find(ER_ERROR_ON_RENAME));
620
ADD_ERROR_MESSAGE(EE_EOFERR, *find(ER_UNEXPECTED_EOF));
621
ADD_ERROR_MESSAGE(EE_CANTLOCK, *find(ER_CANT_LOCK));
622
ADD_ERROR_MESSAGE(EE_DIR, *find(ER_CANT_READ_DIR));
623
ADD_ERROR_MESSAGE(EE_STAT, *find(ER_CANT_GET_STAT));
624
ADD_ERROR_MESSAGE(EE_DISK_FULL, *find(ER_DISK_FULL));
663
626
// Catalog related errors
664
627
ADD_ERROR_MESSAGE(ER_CATALOG_CANNOT_CREATE, N_("Cannot create catalog '%s'."));