示例#1
0
    void RcfSession::sendResponseException(
        const std::exception &e)
    {
        clearParameters();

        const SerializationException *pSE =
            dynamic_cast<const SerializationException *>(&e);

        const RemoteException *pRE =
            dynamic_cast<const RemoteException *>(&e);

        const Exception *pE =
            dynamic_cast<const Exception *>(&e);

        if (pSE)
        {
            RCF_LOG_1()(typeid(*pSE))(*pSE) << "Returning RCF::SerializationException to client.";
            encodeRemoteException(
                mOut,
                RemoteException(
                    Error( pSE->getError() ),
                    pSE->what(),
                    pSE->getContext(),
                    typeid(*pSE).name()));
        }
        else if (pRE)
        {
            RCF_LOG_1()(typeid(*pRE))(*pRE) << "Returning RCF::RemoteException to client.";
            try
            {
                encodeRemoteException(mOut, *pRE);
            }
            catch(const RCF::Exception &e)
            {
                encodeRemoteException(
                    mOut,
                    RemoteException(
                        _RcfError_Serialization(typeid(*pRE).name(), typeid(e).name(), e.getError().getErrorString()),
                        e.getWhat(),
                        e.getContext(),
                        typeid(e).name()));
            }
            catch(const std::exception &e)
            {
                encodeRemoteException(
                    mOut,
                    RemoteException(
                        _RcfError_Serialization(typeid(*pRE).name(), typeid(e).name(), e.what()),
                        e.what(),
                        "",
                        typeid(e).name()));
            }
        }
        else if (pE)
        {
            RCF_LOG_1()(typeid(*pE))(*pE) << "Returning RCF::Exception to client.";
            encodeRemoteException(
                mOut,
                RemoteException(
                    Error( pE->getError() ),
                    pE->getSubSystemError(),
                    pE->getSubSystem(),
                    pE->what(),
                    pE->getContext(),
                    typeid(*pE).name()));
        }
        else
        {
            RCF_LOG_1()(typeid(e))(e) << "Returning std::exception to client.";
            encodeRemoteException(
                mOut,
                RemoteException(
                    _RcfError_AppException(typeid(e).name(), e.what()),
                    e.what(),
                    "",
                    typeid(e).name()));
        }

        sendSessionResponse();

        RCF_LOG_2() << "RcfServer - end remote call. " << mCurrentCallDesc;
    }
示例#2
0
    void RcfSession::sendResponseException(
        const std::exception &e)
    {
        clearParameters();

        const SerializationException *pSE =
            dynamic_cast<const SerializationException *>(&e);

        const RemoteException *pRE =
            dynamic_cast<const RemoteException *>(&e);

        const Exception *pE =
            dynamic_cast<const Exception *>(&e);

        if (pSE)
        {
            RCF_LOG_1()(typeid(*pSE))(*pSE) << "Encoding SerializationException.";
            encodeRemoteException(
                mOut,
                RemoteException(
                    Error( pSE->getError() ),
                    pSE->what(),
                    pSE->getContext(),
                    typeid(*pSE).name()));
        }
        else if (pRE)
        {
            RCF_LOG_1()(typeid(*pRE))(*pRE) << "Encoding RemoteException.";
            try
            {
                encodeRemoteException(mOut, *pRE);
            }
            catch(const RCF::Exception &e)
            {
                encodeRemoteException(
                    mOut,
                    RemoteException(
                        _RcfError_Serialization(typeid(*pRE).name(), typeid(e).name(), e.getError().getErrorString()),
                        e.getWhat(),
                        e.getContext(),
                        typeid(e).name()));
            }
            catch(const std::exception &e)
            {
                encodeRemoteException(
                    mOut,
                    RemoteException(
                        _RcfError_Serialization(typeid(*pRE).name(), typeid(e).name(), e.what()),
                        e.what(),
                        "",
                        typeid(e).name()));
            }
        }
        else if (pE)
        {
            RCF_LOG_1()(typeid(*pE))(*pE) << "Encoding Exception.";
            encodeRemoteException(
                mOut,
                RemoteException(
                    Error( pE->getError() ),
                    pE->getSubSystemError(),
                    pE->getSubSystem(),
                    pE->what(),
                    pE->getContext(),
                    typeid(*pE).name()));
        }
        else
        {
            RCF_LOG_1()(typeid(e))(e) << "Encoding std::exception.";
            encodeRemoteException(
                mOut,
                RemoteException(
                    _RcfError_UserModeException(typeid(e).name(), e.what()),
                    e.what(),
                    "",
                    typeid(e).name()));
        }

        sendSessionResponse();
    }