Skip to content

Commit

Permalink
Refactoring of exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
igormironchik committed May 4, 2017
1 parent ada118a commit cfaf209
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions Args/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,49 +49,25 @@ class BaseException
: public std::logic_error
{
public:
explicit BaseException( const String & what )
#ifdef ARGS_QSTRING_BUILD
: std::logic_error( ( (QString) what ).toLocal8Bit().toStdString() )
, m_what( what )
#elif defined( ARGS_WSTRING_BUILD )
: std::logic_error( "Please use desc() method to get exception "
"description when compiling with std::wstring." )
, m_what( what )
#else
: std::logic_error( what )
#endif
explicit BaseException( String what )
: std::logic_error( "Please use desc() method of the exception." )
, m_what( std::move( what ) )
{
}

virtual ~BaseException() noexcept
{
}

#ifdef ARGS_WSTRING_BUILD
//! \return What as std::wstring.
const String & desc() const noexcept
{
return m_what;
}

private:
//! What happened?
String m_what;
#elif defined( ARGS_QSTRING_BUILD )
//! \return What as QString.
const String & desc() const noexcept
{
return m_what;
}

private:
String m_what;
#else
//! \return What?
String desc() const
{
return what();
}
#endif
}; // class BaseException


Expand Down

0 comments on commit cfaf209

Please sign in to comment.