예제 #1
0
bool DigiDoc::parseException( const Exception &e, QStringList &causes,
	Exception::ExceptionCode &code, int &ddocError )
{
	causes << from( e.getMsg() );
	if( e.ddoc() > 0 )
		ddocError = e.ddoc();
	switch( e.code() )
	{
	case Exception::CertificateRevoked:
	case Exception::CertificateUnknown:
	case Exception::OCSPTimeSlot:
	case Exception::OCSPRequestUnauthorized:
	case Exception::PINCanceled:
	case Exception::PINFailed:
	case Exception::PINIncorrect:
	case Exception::PINLocked:
		code = e.code();
		return false;
	default: break;
	}
	Q_FOREACH( const Exception &c, e.getCauses() )
		if( !parseException( c, causes, code, ddocError ) )
			return false;
	return true;
}
예제 #2
0
void kdrive::connector::raiseError(Connector& connector, const Exception& exception)
{
	const int errorCode = exception.code() ? exception.code() : ConnectorErrorCodes::ConnectorError;

	connector.setLastErrorCode(errorCode);
	connector.setLastErrorMessage(exception.displayText());
	connector.routeEvent(ConnectorEvents::Error);
	exception.rethrow();
}
예제 #3
0
std::string getExceptionMessage(const Exception & e, bool with_stacktrace, bool check_embedded_stacktrace)
{
    std::stringstream stream;

    try
    {
        std::string text = e.displayText();

        bool has_embedded_stack_trace = false;
        if (check_embedded_stacktrace)
        {
            auto embedded_stack_trace_pos = text.find("Stack trace");
            has_embedded_stack_trace = embedded_stack_trace_pos != std::string::npos;
            if (!with_stacktrace && has_embedded_stack_trace)
            {
                text.resize(embedded_stack_trace_pos);
                Poco::trimRightInPlace(text);
            }
        }

        stream << "Code: " << e.code() << ", e.displayText() = " << text;

        if (with_stacktrace && !has_embedded_stack_trace)
            stream << ", Stack trace:\n\n" << e.getStackTrace().toString();
    }
    catch (...) {}

    return stream.str();
}
예제 #4
0
      Exception( const std::string& whoString, int whereLine,
                 const std::string& whatString, const Exception& inner )
      {
        std::stringstream lineString;
        lineString << whereLine;

        _what = whoString + "(" + lineString.str() + "): " + whatString + "\n\t" + inner.what();
        _code = inner.code();
      }
예제 #5
0
bool SocketSender::run(Exception& ex) {
	if (!_pSocket) {
		ex.set(Exception::SOCKET, "SocketSender ", name, " started in parallel without pointer of socket");
		return false;
	}
	// send
	Exception exc;
	shared_ptr<SocketSender> pThis(_pThis);
	_pSocket->send(exc, pThis);
	if (exc.code() != Exception::ASSERT)
		ex.set(exc);
	return true;
}
예제 #6
0
bool DigiDoc::parseException( const Exception &e, QStringList &causes,
	Exception::ExceptionCode &code, int &ddocError )
{
	causes << QString( "%1:%2 %3").arg( QFileInfo(from(e.file())).fileName() ).arg( e.line() ).arg( from(e.msg()) );
	if( e.code() & Exception::DDocError )
		ddocError = e.code() & ~Exception::DDocError;
	switch( e.code() )
	{
	case Exception::CertificateRevoked:
	case Exception::CertificateUnknown:
	case Exception::OCSPTimeSlot:
	case Exception::OCSPRequestUnauthorized:
	case Exception::PINCanceled:
	case Exception::PINFailed:
	case Exception::PINIncorrect:
	case Exception::PINLocked:
		code = e.code();
	default: break;
	}
	Q_FOREACH( const Exception &c, e.causes() )
		if( !parseException( c, causes, code, ddocError ) )
			return false;
	return true;
}
예제 #7
0
void writeException(const Exception & e, WriteBuffer & buf, bool with_stack_trace)
{
    writeBinary(e.code(), buf);
    writeBinary(String(e.name()), buf);
    writeBinary(e.displayText(), buf);

    if (with_stack_trace)
        writeBinary(e.getStackTrace().toString(), buf);
    else
        writeBinary(String(), buf);

    bool has_nested = e.nested() != nullptr;
    writeBinary(has_nested, buf);

    if (has_nested)
        writeException(Exception(Exception::CreateFromPoco, *e.nested()), buf, with_stack_trace);
}
예제 #8
0
void WSSession::packetHandler(PacketReader& packet) {
	UInt8 type = 0;
	Exception ex;
	if(peer.connected) {
		type = packet.read8();	
		
		switch(type) {
			case WS::TYPE_BINARY: {
				RawReader reader(packet);
				peer.onMessage(ex, "onMessage",reader,WS::TYPE_BINARY);
				break;
			}
			case WS::TYPE_TEXT: {
				if(!JSONReader::IsValid(packet)) {
					RawReader reader(packet);
					peer.onMessage(ex, "onMessage",reader);
					break;
				}
				JSONReader reader(packet);
				if(reader.followingType()!=JSONReader::STRING) {
					peer.onMessage(ex, "onMessage",reader);
					break;
				}
				string name;
				reader.readString(name);
				if(name=="__publish") {
					if(reader.followingType()!=JSONReader::STRING) {
						ex.set(Exception::PROTOCOL, "__publish method takes a stream name in first parameter",WS::CODE_MALFORMED_PAYLOAD);
						break;
					}
					reader.readString(name);
					if(_pPublication)
						invoker.unpublish(peer,_pPublication->name());
					_pPublication = invoker.publish(ex, peer,name);
				} else if(name=="__play") {
					if(reader.followingType()!=JSONReader::STRING) {
						ex.set(Exception::PROTOCOL, "__play method takes a stream name in first parameter",WS::CODE_MALFORMED_PAYLOAD);
						break;
					}
					reader.readString(name);
					
					closeSusbcription();
				} else if(name=="__closePublish") {
					closePublication();
				} else if(name=="__closePlay") {
					closeSusbcription();
				} else if (name == "__close") {
					closePublication();
					closeSusbcription();
					
				} else if(_pPublication) {
					reader.reset();
					_pPublication->pushData(reader);
				} else
					peer.onMessage(ex, name,reader);
				break;
			}
			case WS::TYPE_CLOSE:
				_writer.close(packet.available() ? packet.read16() : 0);
				break;
			case WS::TYPE_PING:
				_writer.writePong(packet.current(),packet.available());
				break;
			case WS::TYPE_PONG:
				peer.setPing(_writer.ping = (UInt16)(_time.elapsed()/1000));
				break;
			default:
				ex.set(Exception::PROTOCOL, Format<UInt8>("Type %#x unknown", type), WS::CODE_MALFORMED_PAYLOAD);
				break;
		}
		
		if (ex) {
			ERROR(ex.error());
			_writer.close((ex.code()==Exception::APPLICATION || ex.code() == Exception::SOFTWARE) ? WS::CODE_PROTOCOL_ERROR : ex.code());	
		}
		
	}

	if(!peer.connected || type==WS::TYPE_CLOSE)
		kill();
	else
		_writer.flush();
}
예제 #9
0
void RestBaseHandler::handleError (Exception const& ex) {
  generateError(HttpResponse::responseCode(ex.code()),
                ex.code(),
                ex.what());
}
예제 #10
0
QString Stringify::errorMessage( const Exception &exception )
{
  QString message = "";

  switch ( exception.code() ) {
  case Exception::LoadError:
    message = i18nc( "@item", "Load Error" );
    break;
  case Exception::SaveError:
    message = i18nc( "@item", "Save Error" );
    break;
  case Exception::ParseErrorIcal:
    message = i18nc( "@item", "Parse Error in libical" );
    break;
  case Exception::ParseErrorKcal:
    message = i18nc( "@item", "Parse Error in the kcalcore library" );
    break;
  case Exception::NoCalendar:
    message = i18nc( "@item", "No calendar component found." );
    break;
  case Exception::CalVersion1:
    message = i18nc( "@item", "Expected iCalendar, got vCalendar format" );
    break;
  case Exception::CalVersion2:
    message = i18nc( "@item", "iCalendar Version 2.0 detected." );
    break;
  case Exception::CalVersionUnknown:
    message = i18nc( "@item", "Expected iCalendar, got unknown format" );
    break;
  case Exception::Restriction:
    message = i18nc( "@item", "Restriction violation" );
    break;
  case Exception::NoWritableFound:
    message = i18nc( "@item", "No writable resource found" );
    break;
  case Exception::SaveErrorOpenFile:
    Q_ASSERT( exception.arguments().count() == 1 );
    message = i18nc( "@item", "Error saving to '%1'.", exception.arguments()[0] );
    break;
  case Exception::SaveErrorSaveFile:
    Q_ASSERT( exception.arguments().count() == 1 );
    message = i18nc( "@item", "Could not save '%1'", exception.arguments()[0] );
    break;
  case Exception::LibICalError:
    message = i18nc( "@item", "libical error" );
    break;
  case Exception::VersionPropertyMissing:
    message = i18nc( "@item", "No VERSION property found" );
    break;
  case Exception::ExpectedCalVersion2:
    message = i18nc( "@item", "Expected iCalendar, got vCalendar format" );
    break;
  case Exception::ExpectedCalVersion2Unknown:
    message = i18nc( "@item", "Expected iCalendar, got unknown format" );
    break;
  case Exception::ParseErrorNotIncidence:
    message = i18nc( "@item", "object is not a freebusy, event, todo or journal" );
    break;
  case Exception::ParseErrorEmptyMessage:
    message = i18nc( "@item", "messageText is empty, unable to parse into a ScheduleMessage" );
    break;
  case Exception::ParseErrorUnableToParse:
    message = i18nc( "@item", "icalparser is unable to parse messageText into a ScheduleMessage" );
    break;
  case Exception::ParseErrorMethodProperty:
    message = i18nc( "@item", "message does not contain ICAL_METHOD_PROPERTY" );
    break;
  case Exception::UserCancel:
    // no real error; the user canceled the operation
    break;

  }

  return message;
}