Skip to content
Snippets Groups Projects
Commit 70312a50 authored by g0dil's avatar g0dil
Browse files

Utils: Rename SystemException::code() to SystemException::errorNumber()

Utils: Rename Daemon::fail() to Daemon::exit()
parent e825ade1
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,7 @@ prefix_ void senf::ReadHelper<Handle>::process(Handle handle,
}
}
catch (senf::SystemException const & ex) {
errno_ = ex.code();
errno_ = ex.errorNumber();
done();
return;
}
......
......@@ -87,7 +87,7 @@ prefix_ void senf::WriteHelper<Handle>::process(Handle handle,
}
}
catch (senf::SystemException const & ex) {
errno_ = ex.code();
errno_ = ex.errorNumber();
done();
return;
}
......
......@@ -151,15 +151,15 @@ prefix_ void senf::Daemon::detach()
namespace {
/* Purposely *not* derived from std::exception */
struct DaemonFailureException {
DaemonFailureException(unsigned c) : code(c) {}
struct DaemonExitException {
DaemonExitException(unsigned c) : code(c) {}
unsigned code;
};
}
prefix_ void senf::Daemon::fail(unsigned code)
prefix_ void senf::Daemon::exit(unsigned code)
{
throw DaemonFailureException(code);
throw DaemonExitException(code);
}
prefix_ int senf::Daemon::start(int argc, char const ** argv)
......@@ -182,8 +182,8 @@ prefix_ int senf::Daemon::start(int argc, char const ** argv)
main();
}
catch (DaemonFailureException & e) {
return e.code > 0 ? e.code : 1;
catch (DaemonExitException & e) {
return e.code;
}
#ifdef NDEBUG
......
......@@ -156,7 +156,7 @@ namespace senf {
int argc(); ///< Access command line parameter count
char const ** argv(); ///< Access command line parameters
void fail(unsigned code=1); ///< Terminate daemon with failure
void exit(unsigned code=0); ///< Terminate daemon with failure
///\}
......
......@@ -48,7 +48,7 @@ prefix_ char const * senf::SystemException::what()
return buffer_.c_str();
}
prefix_ int senf::SystemException::code()
prefix_ int senf::SystemException::errorNumber()
const
{
return code_;
......
......@@ -109,12 +109,12 @@ namespace senf {
public:
virtual char const * what() const throw(); ///< Return verbose error description
int code() const; ///< Error code (\c errno number)
int errorNumber() const; ///< Error code (\c errno number)
char const * description() const; ///< Error description (strerror() value)
bool anyOf(int c0, int c1=0, int c2=0, int c3=0, int c4=0, int c5=0,
int c6=0, int c7=0, int c8=0, int c9=0);
///< \c true, if code() is one of \a c0 ... \a c9
///< \c true, if errorNumber() is one of \a c0 ... \a c9
virtual ~SystemException() throw();
......
......@@ -54,7 +54,7 @@ BOOST_AUTO_UNIT_TEST(errnoException)
}
}
catch (senf::SystemException & e) {
BOOST_CHECK_EQUAL( e.code(), ENOENT );
BOOST_CHECK_EQUAL( e.errorNumber(), ENOENT );
BOOST_CHECK_EQUAL( e.what(), "::open(): (2) No such file or directory: x=1, y=2" );
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment