error.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "error.h"
00023 #include <sstream>
00024 #include <string.h>
00025
00026 using namespace std;
00027
00028 namespace Barry {
00029
00030 std::string BadSize::GetMsg(const char *msg, unsigned int d, unsigned int r)
00031 {
00032 std::ostringstream oss;
00033 oss << msg << ": Bad packet size, not enough data: DataSize(): " << d
00034 << ". Required size: " << r;
00035 return oss.str();
00036 }
00037
00038 std::string BadSize::GetMsg(unsigned int p, unsigned int d, unsigned int r)
00039 {
00040 std::ostringstream oss;
00041 oss << "Bad packet size. Packet: " << p
00042 << ". DataSize(): " << d
00043 << ". Required size: " << r;
00044 return oss.str();
00045 }
00046
00047 std::string ErrnoError::GetMsg(const std::string &msg, int err)
00048 {
00049 std::ostringstream oss;
00050 oss << msg << ": (errno " << err << ") " << strerror(err);
00051 return oss.str();
00052 }
00053
00054 }
00055