mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Correct and unify exit codes
This commit is contained in:
parent
095f7ab591
commit
c8104cb2ee
@ -431,7 +431,7 @@ catch (const Exception & e)
|
|||||||
bool need_print_stack_trace = config().getBool("stacktrace", false) && e.code() != ErrorCodes::NETWORK_ERROR;
|
bool need_print_stack_trace = config().getBool("stacktrace", false) && e.code() != ErrorCodes::NETWORK_ERROR;
|
||||||
std::cerr << getExceptionMessage(e, need_print_stack_trace, true) << std::endl << std::endl;
|
std::cerr << getExceptionMessage(e, need_print_stack_trace, true) << std::endl << std::endl;
|
||||||
/// If exception code isn't zero, we should return non-zero return code anyway.
|
/// If exception code isn't zero, we should return non-zero return code anyway.
|
||||||
return e.code() ? e.code() : -1;
|
return static_cast<UInt8>(e.code()) ? e.code() : -1;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -1390,7 +1390,8 @@ int mainEntryClickHouseClient(int argc, char ** argv)
|
|||||||
catch (const DB::Exception & e)
|
catch (const DB::Exception & e)
|
||||||
{
|
{
|
||||||
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
||||||
return 1;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
catch (const boost::program_options::error & e)
|
catch (const boost::program_options::error & e)
|
||||||
{
|
{
|
||||||
@ -1399,7 +1400,8 @@ int mainEntryClickHouseClient(int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << std::endl;
|
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
||||||
return 1;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,16 +546,18 @@ int mainEntryClickHouseDisks(int argc, char ** argv)
|
|||||||
catch (const DB::Exception & e)
|
catch (const DB::Exception & e)
|
||||||
{
|
{
|
||||||
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
||||||
return 0;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
catch (const boost::program_options::error & e)
|
catch (const boost::program_options::error & e)
|
||||||
{
|
{
|
||||||
std::cerr << "Bad arguments: " << e.what() << std::endl;
|
std::cerr << "Bad arguments: " << e.what() << std::endl;
|
||||||
return 0;
|
return DB::ErrorCodes::BAD_ARGUMENTS;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << std::endl;
|
std::cerr << DB::getCurrentExceptionMessage(true) << std::endl;
|
||||||
return 0;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,8 @@ int mainEntryClickHouseKeeperClient(int argc, char ** argv)
|
|||||||
catch (const DB::Exception & e)
|
catch (const DB::Exception & e)
|
||||||
{
|
{
|
||||||
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
||||||
return 1;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
catch (const boost::program_options::error & e)
|
catch (const boost::program_options::error & e)
|
||||||
{
|
{
|
||||||
@ -458,6 +459,7 @@ int mainEntryClickHouseKeeperClient(int argc, char ** argv)
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << std::endl;
|
std::cerr << DB::getCurrentExceptionMessage(true) << std::endl;
|
||||||
return 1;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ int mainEntryClickHouseKeeper(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ catch (...)
|
|||||||
/// Poco does not provide stacktrace.
|
/// Poco does not provide stacktrace.
|
||||||
tryLogCurrentException("Application");
|
tryLogCurrentException("Application");
|
||||||
auto code = getCurrentExceptionCode();
|
auto code = getCurrentExceptionCode();
|
||||||
return code ? code : -1;
|
return static_cast<UInt8>(code) ? code : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ int mainEntryClickHouseLibraryBridge(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,12 +615,14 @@ catch (const DB::Exception & e)
|
|||||||
{
|
{
|
||||||
bool need_print_stack_trace = getClientConfiguration().getBool("stacktrace", false);
|
bool need_print_stack_trace = getClientConfiguration().getBool("stacktrace", false);
|
||||||
std::cerr << getExceptionMessage(e, need_print_stack_trace, true) << std::endl;
|
std::cerr << getExceptionMessage(e, need_print_stack_trace, true) << std::endl;
|
||||||
return e.code() ? e.code() : -1;
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << getCurrentExceptionMessage(false) << std::endl;
|
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
||||||
return getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalServer::updateLoggerLevel(const String & logs_level)
|
void LocalServer::updateLoggerLevel(const String & logs_level)
|
||||||
@ -1029,7 +1031,7 @@ int mainEntryClickHouseLocal(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
std::cerr << DB::getExceptionMessage(e, false) << std::endl;
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
catch (const boost::program_options::error & e)
|
catch (const boost::program_options::error & e)
|
||||||
{
|
{
|
||||||
@ -1040,6 +1042,6 @@ int mainEntryClickHouseLocal(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1480,5 +1480,5 @@ catch (...)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ int mainEntryClickHouseODBCBridge(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ int mainEntryClickHouseServer(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
std::cerr << DB::getCurrentExceptionMessage(true) << "\n";
|
||||||
auto code = DB::getCurrentExceptionCode();
|
auto code = DB::getCurrentExceptionCode();
|
||||||
return code ? code : 1;
|
return static_cast<UInt8>(code) ? code : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2537,7 +2537,7 @@ catch (...)
|
|||||||
/// Poco does not provide stacktrace.
|
/// Poco does not provide stacktrace.
|
||||||
tryLogCurrentException("Application");
|
tryLogCurrentException("Application");
|
||||||
auto code = getCurrentExceptionCode();
|
auto code = getCurrentExceptionCode();
|
||||||
return code ? code : -1;
|
return static_cast<UInt8>(code) ? code : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<TCPProtocolStackFactory> Server::buildProtocolStackFromConfig(
|
std::unique_ptr<TCPProtocolStackFactory> Server::buildProtocolStackFromConfig(
|
||||||
|
Loading…
Reference in New Issue
Block a user