Example #1
0
 std::string Error::what() const
 {
     int idx = errorIdx(code_);
     std::string msg = std::string(errMsg_[idx].message_);
     std::string::size_type pos;
     pos = msg.find("%0");
     if (pos != std::string::npos) {
         msg.replace(pos, 2, toString(code_));
     }
     if (count_ > 0) {
         pos = msg.find("%1");
         if (pos != std::string::npos) {
             msg.replace(pos, 2, arg1_);
         }
     }
     if (count_ > 1) {
         pos = msg.find("%2");
         if (pos != std::string::npos) {
             msg.replace(pos, 2, arg2_);
         }
     }
     if (count_ > 2) {
         pos = msg.find("%3");
         if (pos != std::string::npos) {
             msg.replace(pos, 2, arg3_);
         }
     }
     return msg;
 }
Example #2
0
 void Error::setMsg()
 {
     int idx = errorIdx(code_);
     msg_ = std::string(_(errMsg_[idx].message_));
     std::string::size_type pos;
     pos = msg_.find("%0");
     if (pos != std::string::npos) {
         msg_.replace(pos, 2, toString(code_));
     }
     if (count_ > 0) {
         pos = msg_.find("%1");
         if (pos != std::string::npos) {
             msg_.replace(pos, 2, arg1_);
         }
     }
     if (count_ > 1) {
         pos = msg_.find("%2");
         if (pos != std::string::npos) {
             msg_.replace(pos, 2, arg2_);
         }
     }
     if (count_ > 2) {
         pos = msg_.find("%3");
         if (pos != std::string::npos) {
             msg_.replace(pos, 2, arg3_);
         }
     }
 }