Пример #1
0
	/**
	 * エラーコードからエラーメッセージの取得(クラス関数)
	 *
	 * @param dwErrCode エラーコード
	 *
	 * @return エラーメッセージ
	 */
	std::string Win32Exception::getErrorMessage( DWORD errorCode )
	{
		// エラーメッセージ用クラス
		class ErrorMessage
		{
		public:

			ErrorMessage() : message_(0) {}
			~ErrorMessage(){ if( message_ != 0 ) ::LocalFree( message_ ); }

			char** operator & (){ return &message_; }
			char* get(){ return message_; }

		private:

			char* message_;
		};

		ErrorMessage message; // メッセージバッファ

		// エラーメッセージの取得
		BOOL ret = ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
								0, errorCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPTSTR)&message, 0, 0 );

		return ret ? message.get() : "未定義エラー";
	}
Пример #2
0
		void ActionCallback(ui::Button * sender)
		{
			message->CloseActiveWindow();
			if(message->callback)
				message->callback->DismissCallback();
			message->SelfDestruct();
		}
Пример #3
0
  size_t CodePage2UnicodeConverter::convertToUnicode(UChar * pclTarget,
      size_t uiTargetMaxLength,
      const char * cpacSource,
      size_t uiSourceLength)
  /* ----------------------------------------------------------------------- */
  {
    size_t                     uiTargetSize;

    assert(iv_uconverter !=NULL);
    UErrorCode err=(UErrorCode)0;
    uiTargetSize = ucnv_toUChars(iv_uconverter, pclTarget, uiTargetMaxLength, cpacSource, uiSourceLength, &err);

    if (!U_SUCCESS(err) &&  err != U_BUFFER_OVERFLOW_ERROR) {
      cout << "ERROR: convertToUnicode " << err << endl;
      ///cerr << "CodePage2UnicodeConverter::getMaximumLength() rc= " << err << endl;
      ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_CODEPAGE_CONV_ERROR);
      errMsg.addParam(err);
      UIMA_EXC_THROW_NEW(CodePageConversionException,
                         UIMA_ERR_CODEPAGE,
                         errMsg,
                         UIMA_MSG_ID_CODEPAGE_CONV_ERROR,
                         ErrorInfo::unrecoverable);
    }
    return uiTargetSize;
    //// return(uiTargetSize / sizeof(UChar));       /* as characters */
  }
Пример #4
0
void WBSDErrorWindow::gotErrorCountMsg(ErrorMessage aMsg){
	myTimer->stop();
	err_query_number=0;
    if (aMsg.getType()==Message::REPLY_ERR_COUNT_ACT){
        err_act=aMsg.getDataInt(0,false,2);
        err_messages_act.clear();
		if (err_act==0){
			clearActiveErrors();
			myTimer->start();
			this->setCursor(Qt::ArrowCursor);
		} else {
			qDebug() << "Get Active Error 0 total "<< err_act;
			itsBaseWindow->addMessageToQue(ErrorMessage(Message::ERR_ACTIVE,0));
		}
        //itsBaseWindow->addMessageToQue(ErrorMessage(Message::ERR_TOTAL_ERRORS_IN_LOG,0));
        return;
    }
    if (aMsg.getType()==Message::REPLY_ERR_COUNT_HIST){
        err_total=aMsg.getDataInt(0,false,2);
        ui->progressBar->setMaximum(err_total);
        if(err_total>0){
            err_messages_hist.clear();
			qDebug() << "Get Historocal Error 0 total " << err_total;
            itsBaseWindow->addMessageToQue(ErrorMessage(Message::ERR_HISTORIC,0));
            return;
		} else {
			myTimer->start();
			this->setCursor(Qt::ArrowCursor);
		}
	}
}
Пример #5
0
bool ErrorMessage::operator==(const ErrorMessage& n) const
{
	// the 'operator==' mthod has to be implemented for the ErrorList wants to do searches
	if (n.text()  == _errorText  ||
	    n.token() == _errorToken ||
	    n.code()  == _errorCode) return true;
	return false;
}
void MainWindowController::ErrorMessageClicked(int32 listIndex)
{
	if (listIndex < 0 || listIndex >= _errorsAndWarnings.size())
		return;
	
	ErrorMessage errorMessage = _errorsAndWarnings[listIndex];	
	BEntry path = errorMessage.FilePath();
	OpenFile(path);	
}
Пример #7
0
/* pop the top of the message stack (and any duplicate messages that have also been added) */
static void pop_message(threadData_t *threadData, bool rollback)
{
  errorext_members *members = getMembers(threadData);
  bool pop_more;
  do {
    ErrorMessage *msg = members->errorMessageQueue->back();
    if (msg->getSeverity() == ErrorLevel_error || msg->getSeverity() == ErrorLevel_internal) members->numErrorMessages--;
    if (msg->getSeverity() == ErrorLevel_warning) members->numWarningMessages--;
    members->errorMessageQueue->pop_back();
    pop_more = (!(members->errorMessageQueue->empty()) && !(rollback && members->errorMessageQueue->size() <= members->checkPoints->back().first) && msg->getFullMessage() == members->errorMessageQueue->back()->getFullMessage());
    delete msg;
  } while (pop_more);
}
Пример #8
0
/* Calls the load method in Model */
void loadFile() {
	//printf("File opened is %s \n", fName.c_str());
	/**if(!Model::getInstance()->loadFile(fName)) {
		ErrorMessage *eMessage = 
		new ErrorMessage(mainWindow, "File is corrupt, please use another file");
		eMessage->buildInterface();
	}**/
	
	if (!Model::getInstance()->loadXML(fName)) {
		ErrorMessage *eMessage = 
		new ErrorMessage(mainWindow, "File may be corrupt, please use another file");
		eMessage->buildInterface();
	}
}
Пример #9
0
void WBSDErrorWindow::gotErrorMsg(ErrorMessage aMsg){
    if (aMsg.getType()==Message::REPLY_ERR_ACT){
        err_messages_act.append(aMsg);
        if (err_messages_act.count()<err_act){
			qDebug() << "Get Active Error " << err_query_number+1;
            itsBaseWindow->addMessageToQue(ErrorMessage(Message::ERR_ACTIVE,++err_query_number));
            return;
        } else {
            clearActiveErrors();
            for (int i=0;i<err_messages_act.count();i++){
                ErrorMessage e=err_messages_act.at(i);
                updateActiveErrors(e.toString());
            }
			myTimer->start();
			this->setCursor(Qt::ArrowCursor);
           // ui->btnSaveErrors->setEnabled(true);
        }
        return;
    }
    if (aMsg.getType()==Message::REPLY_ERR_HIST){
        err_messages_hist.append(aMsg);
        ui->progressBar->setValue(err_messages_hist.count());
        if (err_messages_hist.count()<err_total){
			qDebug() << "Get historic Error " << err_query_number+1;
            itsBaseWindow->addMessageToQue(ErrorMessage(Message::ERR_HISTORIC,++err_query_number));
            return;
        }
        else
        {
            clearHistoryErrors();
            QString aStr="";
            for (int i=0;i<err_messages_hist.count();i++){
                ErrorMessage e=err_messages_hist.at(err_messages_hist.count()-i-1);
                if(e.toString().endsWith("[200:ALM_RESTART]"))
                {
                    continue;
                }
                if (aStr!=e.toString()) {
                    updateHistoryErrors(e.toString());
                    aStr=e.toString();
                }
            }
			err_total=0;
			myTimer->start();
			this->setCursor(Qt::ArrowCursor);
			ui->btnSaveErrors->setEnabled(true);
        }
    }
}
Пример #10
0
		void ActionCallback(ui::Button * sender)
		{
			ui::Engine::Ref().CloseWindow();
			if(message->callback)
				message->callback->DismissCallback();
			message->SelfDestruct();
		}
Пример #11
0
 CodePage2UnicodeConverter::CodePage2UnicodeConverter( const char * crConverterName) :
     iv_uconverter(NULL)
     /* ----------------------------------------------------------------------- */
 {
   UErrorCode err=(UErrorCode)0;
   iv_uconverter = ucnv_open(crConverterName, &err);
   if (!U_SUCCESS(err)) {
     cerr << "CodePage2UnicodeConverter ERROR could not open converter for " << crConverterName << endl;
     ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_CODEPAGE_CONV_ERROR);
     errMsg.addParam(err);
     errMsg.addParam(crConverterName);
     UIMA_EXC_THROW_NEW(CodePageConversionException,
                        UIMA_ERR_CODEPAGE,
                        errMsg,
                        UIMA_MSG_ID_CODEPAGE_CONV_ERROR,
                        ErrorInfo::unrecoverable);
   }
   assert(iv_uconverter != NULL);
 }
Пример #12
0
bool ErrorMessage::operator == (const ErrorMessage &m) const
{
  return dbus_message_is_error(_pvt->msg, m.name());
}
Пример #13
0
void SerialIOPort::importXml(ticpp::Element* pConfig)
{
    ErrorMessage err;
    int speed;
    struct termios newtio;
    std::string framing = pConfig->GetAttributeOrDefault("framing", "8N1");
    std::string flow = pConfig->GetAttributeOrDefault("flow", "none");
    std::string mode = pConfig->GetAttributeOrDefault("mode", "text");
    modeRaw_m = (mode == "raw");
    memset (&newtio, 0, sizeof (newtio));
    pConfig->GetAttribute("speed", &speed);
    newtio.c_cflag = CLOCAL | CREAD;
    newtio.c_iflag = ICRNL;
    newtio.c_oflag = 0;
    newtio.c_lflag = ICANON;

    if (modeRaw_m)
    {
        timeout_m = RuleServer::parseDuration(pConfig->GetAttributeOrDefault("timeout", "0"), false, true) / 100;
        pConfig->GetAttributeOrDefault("msg-length", &msglength_m, 255);
        newtio.c_iflag = 0;
        newtio.c_lflag = 0;
        newtio.c_cc[VTIME] = timeout_m; // inter character timer (x100ms; 0=disabled)
        newtio.c_cc[VMIN]  = msglength_m; // block until timer expires or msglegth bytes are received
    }
    switch (framing[0]) {
        case '5':
            newtio.c_cflag |= CS5;
            break;
        case '6':
            newtio.c_cflag |= CS6;
            break;
        case '7':
            newtio.c_cflag |= CS7;
            break;
        case '8':
            newtio.c_cflag |= CS8;
            break;
        default:
            err << "Unsupported nb of data bits '" << framing[0] << "' for serial port";
            err.logAndThrow(logger_m);
    }
    switch (framing[1]) {
        case 'E':
            newtio.c_cflag |= PARENB;
            break;
        case 'O':
            newtio.c_cflag |= (PARENB | PARODD);
            break;
        case 'N':
            newtio.c_iflag |= IGNPAR;
            break;
        default:
            err << "Unsupported parity '" << framing[1] << "' for serial port";
            err.logAndThrow(logger_m);
    }

    if (framing[2] == '2')
        newtio.c_cflag |= CSTOPB;
    else if (framing[2] != '1') {
        err << "Unsupported nb of stop bits '" << framing[2] << "' for serial port";
        err.logAndThrow(logger_m);
    }

    if (flow == "xon-xoff")
        newtio.c_iflag |= (IXON | IXOFF);
    else if (flow == "rts-cts")
        newtio.c_cflag |= CRTSCTS;
    else if (flow != "none") {
        err << "Unsupported flow control '" << flow << "' for serial port";
        err.logAndThrow(logger_m);
    }

    switch (speed) {
        case 200:
            speed_m = B200;
            break;
        case 300:
            speed_m = B300;
            break;
        case 600:
            speed_m = B600;
            break;
        case 1200:
            speed_m = B1200;
            break;
        case 1800:
            speed_m = B1800;
            break;
        case 2400:
            speed_m = B2400;
            break;
        case 4800:
            speed_m = B4800;
            break;
        case 9600:
            speed_m = B9600;
            break;
        case 19200:
            speed_m = B19200;
            break;
        case 38400:
            speed_m = B38400;
            break;
        case 57600:
            speed_m = B57600;
            break;
        case 115200:
            speed_m = B115200;
            break;
        case 230400:
            speed_m = B230400;
            break;
        default:
            err << "Unsupported speed '" << speed << "' for serial port";
            err.logAndThrow(logger_m);
    }
    cfsetispeed(&newtio, speed_m);
    cfsetospeed(&newtio, speed_m);
    pConfig->GetAttribute("dev", &dev_m);
    newtio_m = newtio;

    IOPort::importXml(pConfig);

    fd_m = open(dev_m.c_str(), O_RDWR | O_NOCTTY );
    if (fd_m >= 0) {
        // Save previous port settings
        tcgetattr(fd_m, &oldtio_m);
        tcflush(fd_m, TCIFLUSH);
        tcsetattr(fd_m, TCSANOW, &newtio_m);
        logger_m.infoStream() << "SerialIOPort configured for device " << dev_m << endlog;
        onConnect();
    }
    else {
        logger_m.errorStream() << "Unable to open device '" << dev_m << "' for ioport " << getID() << endlog;
    }    
}
Пример #14
0
 void DeserializeInvalidInput() const {
     ErrorMessage msg;
     ASSERT_THROW(msg.deserialize("500foobar"), InternalError);
 }