00001
00002
00003
00004
00005 #include <errno.h>
00006
00007 #include <sstream>
00008
00009 #include "exceptions.h"
00010
00011
00012
00013
00014
00025 pthread_exception::pthread_exception(const char *file, const int line,
00026 const int rc, const std::string &str)
00027 : description(str), filename(file), line_number(line), result_code(rc)
00028 {
00029
00030
00031 std::ostringstream ss;
00032
00033 ss << "pthread library operation (" << description << ") failed at "
00034 << filename << ":" << line_number << ": " << ::strerror(result_code);
00035
00036 _what = ss.str();
00037 }
00038
00042 const char *
00043 pthread_exception::what(void) const throw() {
00044 return(_what.c_str());
00045 }
00046
00047
00048
00049
00050
00051
00058 fireball::fireball(const int ec, const std::string &msg,
00059 const bool use_errno) : message(msg), exit_val(ec),
00060 with_errno(use_errno)
00061 {
00062 std::ostringstream ss;
00063
00064 if (with_errno)
00065 saved_errno = errno;
00066
00067 ss << __progname << ": " << message;
00068 if (this->with_errno)
00069 ss << ": " << ::strerror(saved_errno) << " (" << saved_errno << ")";
00070
00072 _what = ss.str();
00073 }
00074
00077 const char *
00078 fireball::what(void) const throw()
00079 {
00080 return(_what.c_str());
00081 }
00082
00085 CMFailure::CMFailure(const std::string &what_failed, bool use_errno)
00086 : saved_errno(errno)
00087 {
00088 std::ostringstream ss;
00089
00090 ss << "Failure of " << what_failed;
00091 if (use_errno) {
00092 ss << ": " << ::strerror(saved_errno);
00093 }
00094
00095 _what = ss.str();
00096 }