reworked exceptions for message value
parent
52734d2f2c
commit
3bb3b5f47e
|
@ -122,21 +122,23 @@ int Unit::load_root(Json::Value loader_root)
|
||||||
throw UnitException("No rectify boolean attribute specified when loading a unit.");
|
throw UnitException("No rectify boolean attribute specified when loading a unit.");
|
||||||
|
|
||||||
// TODO functionize this
|
// TODO functionize this
|
||||||
char * lgn;
|
int uid = getuid();
|
||||||
|
struct passwd * upw;
|
||||||
|
|
||||||
std::string errmsg_user;
|
std::string errmsg_user;
|
||||||
|
|
||||||
// if no user field is specified then default to the currently executing user
|
// if no user field is specified then default to the currently executing user
|
||||||
if ( ( lgn = getlogin() ) == NULL )
|
if ( ( upw = getpwuid(uid) ) == NULL )
|
||||||
{
|
{
|
||||||
throw UnitException( "Could not retrieve current user." );
|
throw UnitException( "Could not retrieve current user." );
|
||||||
} else {
|
} else {
|
||||||
errmsg_user = lgn;
|
errmsg_user = upw->pw_name;
|
||||||
}
|
}
|
||||||
// -TODO
|
// -TODO
|
||||||
|
|
||||||
|
|
||||||
if ( loader_root.isMember( "user" ) )
|
if ( loader_root.isMember( "user" ) )
|
||||||
{ this->user = loader_root.get( "user", errmsg_user ).asString(); } else this->user = lgn;
|
{ this->user = loader_root.get( "user", errmsg_user ).asString(); } else this->user = errmsg_user;
|
||||||
|
|
||||||
|
|
||||||
// TODO functionalize this
|
// TODO functionalize this
|
||||||
|
|
Loading…
Reference in New Issue