Exception: tryRethrow() can be used to throw in all cases
It is useful to let tryRethrow be used in a mode where it never returns. The PIM Manager will use that.
This commit is contained in:
parent
771d630400
commit
501c32c06d
|
@ -882,7 +882,7 @@ SyncMLStatus Exception::handle(SyncMLStatus *status,
|
|||
return status ? *status : new_status;
|
||||
}
|
||||
|
||||
void Exception::tryRethrow(const std::string &explanation)
|
||||
void Exception::tryRethrow(const std::string &explanation, bool mustThrow)
|
||||
{
|
||||
static const std::string statusre = ".* \\((?:local|remote), status (\\d+)\\)";
|
||||
int status;
|
||||
|
@ -902,6 +902,10 @@ void Exception::tryRethrow(const std::string &explanation)
|
|||
SE_THROW_EXCEPTION_STATUS(StatusException, details, (SyncMLStatus)status);
|
||||
}
|
||||
}
|
||||
|
||||
if (mustThrow) {
|
||||
throw std::runtime_error(explanation);
|
||||
}
|
||||
}
|
||||
|
||||
void Exception::tryRethrowDBus(const std::string &error)
|
||||
|
|
|
@ -534,9 +534,12 @@ class Exception : public std::runtime_error
|
|||
/**
|
||||
* Tries to identify exception class based on explanation string created by
|
||||
* handle(). If successful, that exception is throw with the same
|
||||
* attributes as in the original exception. Otherwise parse() returns.
|
||||
* attributes as in the original exception.
|
||||
*
|
||||
* If not, tryRethrow() returns (mustThrow false) or throws a std::runtime_error
|
||||
* with the explanation as text.
|
||||
*/
|
||||
static void tryRethrow(const std::string &explanation);
|
||||
static void tryRethrow(const std::string &explanation, bool mustThrow = false);
|
||||
|
||||
/**
|
||||
* Same as tryRethrow() for strings with a 'org.syncevolution.xxxx:' prefix,
|
||||
|
|
Loading…
Reference in a new issue