Use exit macros from standard library

This commit is contained in:
Martchus 2023-06-03 17:18:59 +02:00
parent b3dd694a1c
commit ce6da89a40
1 changed files with 12 additions and 11 deletions

View File

@ -38,6 +38,7 @@
#include <algorithm> #include <algorithm>
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#include <cstdlib>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <string_view> #include <string_view>
@ -778,10 +779,10 @@ int ServiceSetup::run()
#ifndef CPP_UTILITIES_DEBUG_BUILD #ifndef CPP_UTILITIES_DEBUG_BUILD
} catch (const std::exception &e) { } catch (const std::exception &e) {
cerr << Phrases::SubError << e.what() << endl; cerr << Phrases::SubError << e.what() << endl;
return -1; return EXIT_FAILURE + 1;
} catch (...) { } catch (...) {
cerr << Phrases::SubError << "An unknown error occurred." << endl; cerr << Phrases::SubError << "An unknown error occurred." << endl;
return -2; return EXIT_FAILURE + 1;
} }
#endif #endif
@ -806,13 +807,13 @@ int ServiceSetup::run()
} catch (const boost::exception &e) { } catch (const boost::exception &e) {
cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << boost::diagnostic_information(e) cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << boost::diagnostic_information(e)
<< Phrases::EndFlush; << Phrases::EndFlush;
return -3; return EXIT_FAILURE + 2;
} catch (const std::exception &e) { } catch (const std::exception &e) {
cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << e.what() << Phrases::EndFlush; cerr << Phrases::ErrorMessage << "Server terminated due to exception: " << Phrases::End << " " << e.what() << Phrases::EndFlush;
return -3; return EXIT_FAILURE + 2;
} catch (...) { } catch (...) {
cerr << Phrases::ErrorMessage << "Server terminated due to an unknown error." << Phrases::EndFlush; cerr << Phrases::ErrorMessage << "Server terminated due to an unknown error." << Phrases::EndFlush;
return -4; return EXIT_FAILURE + 2;
} }
#else #else
} }
@ -833,14 +834,14 @@ int ServiceSetup::run()
#ifndef CPP_UTILITIES_DEBUG_BUILD #ifndef CPP_UTILITIES_DEBUG_BUILD
} catch (const std::exception &e) { } catch (const std::exception &e) {
cerr << Phrases::ErrorMessage << "Exception occurred when terminating server: " << Phrases::End << " " << e.what() << Phrases::EndFlush; cerr << Phrases::ErrorMessage << "Exception occurred when terminating server: " << Phrases::End << " " << e.what() << Phrases::EndFlush;
return -5; return EXIT_FAILURE + 3;
} catch (...) { } catch (...) {
cerr << Phrases::ErrorMessage << "Unknown error occurred when terminating server." << Phrases::EndFlush; cerr << Phrases::ErrorMessage << "Unknown error occurred when terminating server." << Phrases::EndFlush;
return -6; return EXIT_FAILURE + 3;
} }
#endif #endif
return 0; return EXIT_SUCCESS;
} }
int ServiceSetup::fixDb() int ServiceSetup::fixDb()
@ -855,13 +856,13 @@ int ServiceSetup::fixDb()
#ifndef CPP_UTILITIES_DEBUG_BUILD #ifndef CPP_UTILITIES_DEBUG_BUILD
} catch (const std::exception &e) { } catch (const std::exception &e) {
cerr << Phrases::ErrorMessage << "Exception occurred when terminating server: " << Phrases::End << " " << e.what() << Phrases::EndFlush; cerr << Phrases::ErrorMessage << "Exception occurred when terminating server: " << Phrases::End << " " << e.what() << Phrases::EndFlush;
return -5; return EXIT_FAILURE + 4;
} catch (...) { } catch (...) {
cerr << Phrases::ErrorMessage << "Unknown error occurred when terminating server." << Phrases::EndFlush; cerr << Phrases::ErrorMessage << "Unknown error occurred when terminating server." << Phrases::EndFlush;
return -6; return EXIT_FAILURE + 4;
} }
#endif #endif
return 0; return EXIT_SUCCESS;
} }
void ServiceSetup::Locks::clear() void ServiceSetup::Locks::clear()