~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.cc

Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <drizzled/definitions.h>
28
28
#include <drizzled/error.h>
29
29
#include <drizzled/gettext.h>
30
 
 
31
30
#include <drizzled/identifier.h>
 
31
#include <drizzled/util/find_ptr.h>
32
32
 
33
33
#include <boost/unordered_map.hpp>
34
34
#include <exception>
259
259
      MyFlags   Flags
260
260
*/
261
261
 
262
 
void my_message(drizzled::error_t error, const char *str, register myf MyFlags)
 
262
void my_message(drizzled::error_t error, const char *str, myf MyFlags)
263
263
{
264
264
  (*error_handler_hook)(error, str, MyFlags);
265
265
}
271
271
                   const std::string &error_name,
272
272
                   const std::string &message)
273
273
{
274
 
  if (mapping_.find(error_num) == mapping_.end())
 
274
  if (not mapping_.count(error_num))
275
275
  {
276
276
    // Log the error.
277
277
    mapping_[error_num]= ErrorMap::value_type(error_name, message);
284
284
 
285
285
const std::string &ErrorMap::find(drizzled::error_t error_num) const
286
286
{
287
 
  ErrorMessageMap::const_iterator pos= mapping_.find(error_num);
288
 
  if (pos == mapping_.end())
 
287
  const ErrorMessageMap::mapped_type* pos= find_ptr(mapping_, error_num);
 
288
  if (!pos)
289
289
  {
290
290
    throw ErrorStringNotFound();
291
291
  }
292
 
  return pos->second.second;
 
292
  return pos->second;
293
293
}
294
294
 
295
295
#define ADD_ERROR_MESSAGE(code, msg) add(code, STRINGIFY_ARG(code), msg)
677
677
  ADD_ERROR_MESSAGE(ER_WRONG_NAME_FOR_CATALOG, N_("Invalid catalog name."));
678
678
  ADD_ERROR_MESSAGE(ER_USE_DATA_DICTIONARY, N_("Engine status is now stored in the data_dictionary tables, please use these instead."));
679
679
  ADD_ERROR_MESSAGE(ER_TRANSACTION_ALREADY_STARTED, N_("There is already a transaction in progress"));
680
 
 
 
680
  ADD_ERROR_MESSAGE(ER_NO_LOCK_HELD, N_("No lock is held by this connection."));
681
681
}
682
682
 
683
683
} /* namespace drizzled */