Commit 360c43b0 authored by neverlord's avatar neverlord

inlined exception::reason

parent 51fc3699
......@@ -32,7 +32,7 @@ class actor_exited : public exception
public:
actor_exited(std::uint32_t exit_reason);
std::uint32_t reason() const throw();
inline std::uint32_t reason() const throw();
};
......@@ -59,6 +59,11 @@ class bind_failure : public network_exception
};
inline std::uint32_t exception::reason() const throw()
{
return m_reason;
}
} // namespace cppa
#endif // EXCEPTION_HPP
......@@ -5,6 +5,34 @@
#include <sys/un.h>
#include <stdlib.h>
namespace {
std::string ae_what(std::uint32_t reason)
{
std::ostringstream oss;
oss << "actor exited with reason " << reason;
return oss.str();
}
std::string be_what(int err_code)
{
switch (err_code)
{
case EACCES: return "EACCES: address is protected; root access needed";
case EADDRINUSE: return "EADDRINUSE: address is already in use";
case EBADF: return "EBADF: no valid socket descriptor";
case EINVAL: return "EINVAL: socket already bound to an address";
case ENOTSOCK: return "ENOTSOCK: file descriptor given";
default: break;
}
std::stringstream oss;
oss << "an unknown error occurred (code: " << err_code << ")";
return oss.str();
}
} // namespace <anonymous>
namespace cppa {
exception::exception(const std::string &what_str) : m_what(what_str)
......@@ -24,26 +52,11 @@ const char* exception::what() const throw()
return m_what.c_str();
}
namespace // <anonymous>
{
std::string ae_what(std::uint32_t reason)
{
std::ostringstream oss;
oss << "actor exited with reason " << reason;
return oss.str();
}
} // namespace <anonymous>
actor_exited::actor_exited(std::uint32_t reason) : exception(ae_what(reason))
{
m_reason = reason;
}
std::uint32_t actor_exited::reason() const throw()
{
return m_reason;
}
network_exception::network_exception(const std::string& str) : exception(str)
{
}
......@@ -53,25 +66,6 @@ network_exception::network_exception(std::string&& str)
{
}
namespace // <anonymous>
{
std::string be_what(int err_code)
{
switch (err_code)
{
case EACCES: return "EACCES: address is protected; root access needed";
case EADDRINUSE: return "EADDRINUSE: address is already in use";
case EBADF: return "EBADF: no valid socket descriptor";
case EINVAL: return "EINVAL: socket already bound to an address";
case ENOTSOCK: return "ENOTSOCK: file descriptor given";
default: break;
}
std::stringstream oss;
oss << "an unknown error occurred (code: " << err_code << ")";
return oss.str();
}
} // namespace <anonymous>
bind_failure::bind_failure(int err_code) : network_exception(be_what(err_code))
{
m_errno = err_code;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment