~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Brian Aker
  • Date: 2011-02-01 02:51:01 UTC
  • mto: (2132.1.1 drizzle-build)
  • mto: This revision was merged to the branch mainline in revision 2134.
  • Revision ID: brian@tangent.org-20110201025101-yaj5kkdk2towo6ou
Merge in error message rework. Many error messages are fixed in this patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
487
487
{
488
488
 
489
489
  if (exit_code)
490
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Aborting\n"));
 
490
  {
 
491
    errmsg_printf(error::ERROR, _("Aborting"));
 
492
  }
491
493
  else if (opt_help)
 
494
  {
492
495
    usage();
 
496
  }
 
497
 
493
498
  clean_up(!opt_help && (exit_code));
494
499
  internal::my_end();
495
500
  exit(exit_code);
516
521
  (void) unlink(pid_file.file_string().c_str());        // This may not always exist
517
522
 
518
523
  if (print_message && server_start_time)
519
 
    errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
 
524
    errmsg_printf(drizzled::error::INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
520
525
 
521
526
  session::Cache::singleton().shutdownFirst();
522
527
 
543
548
      tmp_user_info= getpwnam(user);
544
549
      if ((!tmp_user_info || user_id != tmp_user_info->pw_uid) &&
545
550
          global_system_variables.log_warnings)
546
 
            errmsg_printf(ERRMSG_LVL_WARN, _("One can only use the --user switch "
 
551
            errmsg_printf(error::WARN, _("One can only use the --user switch "
547
552
                            "if running as root\n"));
548
553
    }
549
554
    return NULL;
550
555
  }
551
556
  if (not user)
552
557
  {
553
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Please read \"Security\" section of "
 
558
      errmsg_printf(error::ERROR, _("Fatal error: Please read \"Security\" section of "
554
559
                      "the manual to find out how to run drizzled as root!\n"));
555
560
    unireg_abort(1);
556
561
  }
570
575
  return tmp_user_info;
571
576
 
572
577
err:
573
 
  errmsg_printf(ERRMSG_LVL_ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
 
578
  errmsg_printf(error::ERROR, _("Fatal error: Can't change to run as user '%s' ;  "
574
579
                    "Please check that the user exists!\n"),user);
575
580
  unireg_abort(1);
576
581
 
1088
1093
      defaults_file_list.push_back(*it);
1089
1094
    else
1090
1095
    {
1091
 
      errmsg_printf(ERRMSG_LVL_ERROR,
 
1096
      errmsg_printf(error::ERROR,
1092
1097
                  _("Defaults file '%s' not found\n"), (*it).c_str());
1093
1098
      unireg_abort(1);
1094
1099
    }
1131
1136
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1132
1137
  {
1133
1138
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1134
 
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
 
1139
    errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
1135
1140
                  glob_hostname);
1136
1141
    pid_file= "drizzle";
1137
1142
  }
1350
1355
  }
1351
1356
  catch (std::exception&)
1352
1357
  {
1353
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Duplicate entry for command line option\n"));
 
1358
    errmsg_printf(error::ERROR, _("Duplicate entry for command line option\n"));
1354
1359
    unireg_abort(1);
1355
1360
  }
1356
1361
 
1396
1401
  }
1397
1402
  catch (po::validation_error &err)
1398
1403
  {
1399
 
    errmsg_printf(ERRMSG_LVL_ERROR,  
 
1404
    errmsg_printf(error::ERROR,  
1400
1405
                  _("%s: %s.\n"
1401
1406
                    "Use --help to get a list of available options\n"),
1402
1407
                  internal::my_progname, err.what());
1414
1419
  }
1415
1420
  catch (po::validation_error &err)
1416
1421
  {
1417
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1422
    errmsg_printf(error::ERROR,
1418
1423
                  _("%s: %s.\n"
1419
1424
                    "Use --help to get a list of available options\n"),
1420
1425
                  internal::my_progname, err.what());
1427
1432
 
1428
1433
  if (plugin_init(plugins, plugin_options))
1429
1434
  {
1430
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize plugins\n"));
 
1435
    errmsg_printf(error::ERROR, _("Failed to initialize plugins\n"));
1431
1436
    unireg_abort(1);
1432
1437
  }
1433
1438
 
1448
1453
  }
1449
1454
  catch (po::validation_error &err)
1450
1455
  {
1451
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1456
    errmsg_printf(error::ERROR,
1452
1457
                  _("%s: %s.\n"
1453
1458
                    "Use --help to get a list of available options\n"),
1454
1459
                  internal::my_progname, err.what());
1456
1461
  }
1457
1462
  catch (po::invalid_command_line_syntax &err)
1458
1463
  {
1459
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1464
    errmsg_printf(error::ERROR,
1460
1465
                  _("%s: %s.\n"
1461
1466
                    "Use --help to get a list of available options\n"),
1462
1467
                  internal::my_progname, err.what());
1464
1469
  }
1465
1470
  catch (po::unknown_option &err)
1466
1471
  {
1467
 
    errmsg_printf(ERRMSG_LVL_ERROR,
 
1472
    errmsg_printf(error::ERROR,
1468
1473
                  _("%s\nUse --help to get a list of available options\n"),
1469
1474
                  err.what());
1470
1475
    unireg_abort(1);
1476
1481
  }
1477
1482
  catch (po::validation_error &err)
1478
1483
  {
1479
 
    errmsg_printf(ERRMSG_LVL_ERROR,  
 
1484
    errmsg_printf(error::ERROR,  
1480
1485
                  _("%s: %s.\n"
1481
1486
                    "Use --help to get a list of available options\n"),
1482
1487
                  internal::my_progname, err.what());
1514
1519
  if (!(default_charset_info=
1515
1520
        get_charset_by_csname(default_character_set_name, MY_CS_PRIMARY)))
1516
1521
  {
1517
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error getting default charset"));
 
1522
    errmsg_printf(error::ERROR, _("Error getting default charset"));
1518
1523
    return 1;                           // Eof of the list
1519
1524
  }
1520
1525
 
1526
1531
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1527
1532
    if (not default_collation)
1528
1533
    {
1529
 
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1534
      errmsg_printf(error::ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1530
1535
      return 1;
1531
1536
    }
1532
1537
    if (not my_charset_same(default_charset_info, default_collation))
1533
1538
    {
1534
 
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1539
      errmsg_printf(error::ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1535
1540
                    default_collation_name,
1536
1541
                    default_charset_info->csname);
1537
1542
      return 1;
1544
1549
  if (not (character_set_filesystem=
1545
1550
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1546
1551
  {
1547
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Error setting collation"));
 
1552
    errmsg_printf(error::ERROR, _("Error setting collation"));
1548
1553
    return 1;
1549
1554
  }
1550
1555
  global_system_variables.character_set_filesystem= character_set_filesystem;
1552
1557
  if (!(my_default_lc_time_names=
1553
1558
        my_locale_by_name(lc_time_names_name)))
1554
1559
  {
1555
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1560
    errmsg_printf(error::ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1556
1561
    return 1;
1557
1562
  }
1558
1563
  global_system_variables.lc_time_names= my_default_lc_time_names;
1572
1577
  */
1573
1578
  if (table_cache_init())
1574
1579
  {
1575
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not initialize table cache\n"));
 
1580
    errmsg_printf(error::ERROR, _("Could not initialize table cache\n"));
1576
1581
    unireg_abort(1);
1577
1582
  }
1578
1583
 
1587
1592
 
1588
1593
  if (xid_cache_init())
1589
1594
  {
1590
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("XA cache initialization failed: Out of memory\n"));
 
1595
    errmsg_printf(error::ERROR, _("XA cache initialization failed: Out of memory\n"));
1591
1596
    unireg_abort(1);
1592
1597
  }
1593
1598
 
1616
1621
 
1617
1622
  if (plugin::Scheduler::setPlugin(scheduler_name))
1618
1623
  {
1619
 
      errmsg_printf(ERRMSG_LVL_ERROR,
 
1624
      errmsg_printf(error::ERROR,
1620
1625
                   _("No scheduler found, cannot continue!\n"));
1621
1626
      unireg_abort(1);
1622
1627
  }
1641
1646
    engine= plugin::StorageEngine::findByName(name);
1642
1647
    if (engine == NULL)
1643
1648
    {
1644
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s\n"),
 
1649
      errmsg_printf(error::ERROR, _("Unknown/unsupported storage engine: %s\n"),
1645
1650
                    default_storage_engine_str);
1646
1651
      unireg_abort(1);
1647
1652
    }
2160
2165
      drizzled_user= (char *)vm["user"].as<string>().c_str();
2161
2166
 
2162
2167
    else
2163
 
      errmsg_printf(ERRMSG_LVL_WARN, _("Ignoring user change to '%s' because the user was "
 
2168
      errmsg_printf(error::WARN, _("Ignoring user change to '%s' because the user was "
2164
2169
                                       "set to '%s' earlier on the command line\n"),
2165
2170
                    vm["user"].as<string>().c_str(), drizzled_user);
2166
2171
  }
2331
2336
    {
2332
2337
      if (errno != EEXIST)
2333
2338
      {
2334
 
        errmsg_printf(ERRMSG_LVL_ERROR, _("There was an error creating the '%s' part of the path '%s'.  Please check the path exists and is writable.\n"), fs::path(drizzle_tmpdir).leaf().c_str(), drizzle_tmpdir.c_str());
 
2339
        errmsg_printf(error::ERROR, _("There was an error creating the '%s' part of the path '%s'.  Please check the path exists and is writable.\n"), fs::path(drizzle_tmpdir).leaf().c_str(), drizzle_tmpdir.c_str());
2335
2340
        exit(1);
2336
2341
      }
2337
2342
    }
2338
2343
 
2339
2344
    if (stat(drizzle_tmpdir.c_str(), &buf) || (S_ISDIR(buf.st_mode) == false))
2340
2345
    {
2341
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("There was an error opening the path '%s', please check the path exists and is writable.\n"), drizzle_tmpdir.c_str());
 
2346
      errmsg_printf(error::ERROR, _("There was an error opening the path '%s', please check the path exists and is writable.\n"), drizzle_tmpdir.c_str());
2342
2347
      exit(1);
2343
2348
    }
2344
2349
  }