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, ...@@ -85,7 +85,7 @@ prefix_ void senf::ReadHelper<Handle>::process(Handle handle,
} }
} }
catch (senf::SystemException const & ex) { catch (senf::SystemException const & ex) {
errno_ = ex.code(); errno_ = ex.errorNumber();
done(); done();
return; return;
} }
......
...@@ -87,7 +87,7 @@ prefix_ void senf::WriteHelper<Handle>::process(Handle handle, ...@@ -87,7 +87,7 @@ prefix_ void senf::WriteHelper<Handle>::process(Handle handle,
} }
} }
catch (senf::SystemException const & ex) { catch (senf::SystemException const & ex) {
errno_ = ex.code(); errno_ = ex.errorNumber();
done(); done();
return; return;
} }
......
...@@ -151,15 +151,15 @@ prefix_ void senf::Daemon::detach() ...@@ -151,15 +151,15 @@ prefix_ void senf::Daemon::detach()
namespace { namespace {
/* Purposely *not* derived from std::exception */ /* Purposely *not* derived from std::exception */
struct DaemonFailureException { struct DaemonExitException {
DaemonFailureException(unsigned c) : code(c) {} DaemonExitException(unsigned c) : code(c) {}
unsigned code; 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) prefix_ int senf::Daemon::start(int argc, char const ** argv)
...@@ -182,8 +182,8 @@ 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(); main();
} }
catch (DaemonFailureException & e) { catch (DaemonExitException & e) {
return e.code > 0 ? e.code : 1; return e.code;
} }
#ifdef NDEBUG #ifdef NDEBUG
......
...@@ -156,7 +156,7 @@ namespace senf { ...@@ -156,7 +156,7 @@ namespace senf {
int argc(); ///< Access command line parameter count int argc(); ///< Access command line parameter count
char const ** argv(); ///< Access command line parameters 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() ...@@ -48,7 +48,7 @@ prefix_ char const * senf::SystemException::what()
return buffer_.c_str(); return buffer_.c_str();
} }
prefix_ int senf::SystemException::code() prefix_ int senf::SystemException::errorNumber()
const const
{ {
return code_; return code_;
......
...@@ -109,12 +109,12 @@ namespace senf { ...@@ -109,12 +109,12 @@ namespace senf {
public: public:
virtual char const * what() const throw(); ///< Return verbose error description 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) 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, 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); 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(); virtual ~SystemException() throw();
......
...@@ -54,7 +54,7 @@ BOOST_AUTO_UNIT_TEST(errnoException) ...@@ -54,7 +54,7 @@ BOOST_AUTO_UNIT_TEST(errnoException)
} }
} }
catch (senf::SystemException & e) { 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" ); 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