diff --git a/alib2common/src/exception/CommonException.h b/alib2common/src/exception/CommonException.h index 1d9d125da6f58377dc0d31b9403e50b87d7539c6..77b656bfb829958d80ec8e358ba31afb73acd5d5 100644 --- a/alib2common/src/exception/CommonException.h +++ b/alib2common/src/exception/CommonException.h @@ -17,58 +17,112 @@ namespace exception { /** - * Basic exception from which are derived all other exceptions. - * Contains reason why the exception occurred. + * \brief + * Basic exception from which all other exceptions are derived. + * + * Extends standard exception and additionally contains cause, backtrace (if conputed), and copy of command line string used to execute the program. */ class CommonException : public std::exception, public object::ObjectBase { protected: + /** + * \brief + * Programmer supplied identification of the exception cause. + */ std::string m_cause; + + /** + * \brief + * Overiden string representation of the backtrace from the position of the throw. + */ std::string m_backtrace; - std::string m_whatMessage; + + /** + * \brief + * A copy of the command line string resulting in the exception. + */ std::string m_command; + /** + * \brief + * Accumulation of cause, backtrace, and command into one string. + */ + std::string m_whatMessage; + public: + /** + * \brief + * Exception constructor with specified cause. The backtrace is internally computed and the command line is also retrieved from global data registry. + */ explicit CommonException ( std::string cause ); + /** + * \brief + * Constructor allowing specification of all information about the exception, its cause, backtrace of where it happened, and the command executed that resulted in the exception + */ explicit CommonException ( std::string cause, std::string backtrace, std::string command ); - virtual object::ObjectBase * clone ( ) const &; + /** + * @copydoc object::ObjectBase::clone ( ) const & + */ + virtual object::ObjectBase * clone ( ) const & override; - virtual object::ObjectBase * clone ( ) &&; + /** + * @copydoc object::ObjectBase::clone ( ) && + */ + virtual object::ObjectBase * clone ( ) && override; - virtual int compare ( const ObjectBase & other ) const { + /** + * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const + */ + virtual int compare ( const ObjectBase & other ) const override { if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); } - virtual int compare ( const CommonException & other ) const; + /** + * The actual compare method + * + * \param other the other instance + * + * \returns the actual relation between two by type same expression instances + */ + int compare ( const CommonException & other ) const; /** - * @return reason why the exception occurred + * \return reason why the exception occurred */ - const char * what ( ) const noexcept; + virtual const char * what ( ) const noexcept override; /** - * @return reason why the exception occurred + * \return reason why the exception occurred */ const std::string & getCause ( ) const; /** - * @return reason why the exception occurred + * \return reason why the exception occurred */ const std::string & getBacktrace ( ) const; /** - * @return reason why the exception occurred + * \return reason why the exception occurred */ const std::string & getCommand ( ) const; - virtual void operator >>( std::ostream & os ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const + */ + virtual void operator >>( std::ostream & out ) const override; - virtual explicit operator std::string ( ) const; + /** + * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const + */ + virtual explicit operator std::string ( ) const override; - virtual object::ObjectBase * inc ( ) &&; + /** + * @copydoc object::ObjectBase::inc ( ) && + */ + virtual object::ObjectBase * inc ( ) && override; }; } /* namespace exception */