1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #ifndef _RVC_CATCH_H__
- #define _RVC_CATCH_H__
- #pragma once
- #include <exception>
- #include <stdexcept>
- #include <cstring>
- #include <iostream>
- #include "SpComm.hpp"
- /** we should integrate it with SpBase.h at the future*/
- #define SPCATCH_NOT_IMPLEMENTED throw ::SP::Catch::NotImplementedException( SP_INTERNAL_LINEINFO )
- namespace SP {
- namespace Catch {
- class CBaseException : public std::exception
- {
- public:
- CBaseException(const ErrorCodeEnum& ec, ::SP::Detail::SourceLineInfo const& lineInfo)
- :m_errorCode(ec),m_lineInfo(lineInfo)
- {
- std::ostringstream oss;
- oss << m_lineInfo << " occurs: " << SpStrError(m_errorCode);
- m_what = oss.str().c_str();
- }
- CBaseException(::SP::Detail::SourceLineInfo const& lineInfo)
- :CBaseException(Error_Exception, lineInfo) {}
- virtual ~CBaseException() noexcept {}
- virtual const char* what() const noexcept
- {
- return m_what;
- }
- protected:
- ErrorCodeEnum m_errorCode;
- ::SP::Detail::SourceLineInfo m_lineInfo;
- CSimpleStringA m_what;
- };
- class NotImplementedException : public CBaseException
- {
- public:
- NotImplementedException(::SP::Detail::SourceLineInfo const& lineInfo)
- :CBaseException(Error_NotImpl, lineInfo)
- {
- }
- };
- class CBaseRTException : public std::runtime_error
- {
- public:
- CBaseRTException(const char* msg) :std::runtime_error(msg)
- {}
- CBaseRTException() = default;
- ~CBaseRTException() = default;
- };
- }
- }
- #endif /** _RVC_CATCH_H__*/
|