From: Davin McCall Date: Mon, 16 Sep 2019 09:02:57 +0000 (+1000) Subject: Convert system_error to service_load_exc in load_service. X-Git-Tag: v0.8.0~40 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f3940c069aad1b2bc6b29667c3defd4eaa087ba2;p=oweals%2Fdinit.git Convert system_error to service_load_exc in load_service. --- diff --git a/src/load-service.cc b/src/load-service.cc index 85cb250..b556588 100644 --- a/src/load-service.cc +++ b/src/load-service.cc @@ -383,10 +383,9 @@ static bool starts_with(string s, const char *prefix) return *prefix == 0; } -// Find a service record, or load it from file. If the service has -// dependencies, load those also. +// Find a service record, or load it from file. If the service has dependencies, load those also. // -// Might throw a ServiceLoadExc exception if a dependency cycle is found or if another +// Throws service_load_exc (or subclass) if a dependency cycle is found or if another // problem occurs (I/O error, service description not found etc). Throws std::bad_alloc // if a memory allocation failure occurs. // @@ -833,8 +832,14 @@ service_record * dirload_service_set::load_service(const char * name) delete rval; throw service_description_exc(name, std::move(setting_exc.get_info())); } - catch (...) { - // Must remove the dummy service record. + catch (std::system_error &sys_err) + { + records.erase(std::find(records.begin(), records.end(), rval)); + delete rval; + throw service_description_exc(name, sys_err.what()); + } + catch (...) // (should only be std::bad_alloc) + { records.erase(std::find(records.begin(), records.end(), rval)); delete rval; throw;