Code View

plugin / plugin-2.2.0.0 / src / dso / Exception.cpp
// SPDX-License-Identifier: MIT
#include "Exception.hh"
#include "ExceptionMessages.hh"

namespace fedem
{
  namespace exception
  {
    Exception::Exception( ) noexcept
      : exceptionLineNumber( 0 )
    {
    }

    Exception::Exception( Exception const& e ) noexcept
      : std::exception( e ),
        exceptionFilename( e.exceptionFilename ),
        exceptionLineNumber( e.exceptionLineNumber )
    {
    }

    Exception::~Exception( ) noexcept = default;

    Exception& Exception::operator=( Exception const& e ) noexcept
    {
      if( this != &e )
      {
        std::exception::operator=( e );
        exceptionLineNumber = e.exceptionLineNumber;
        exceptionFilename   = e.exceptionFilename;
      }

      return *this;
    }

    char const* Exception::what( ) const noexcept
    {
      exceptionDescription = whatStr( );
      return exceptionDescription.c_str( );
    }

    std::string const Exception::description( ) const noexcept
    {
      std::string desc = descriptionHead( whatStr( ) );
#ifndef NDEBUG
      desc.append( descriptionOptional( filename( ), lineNumber( ) ) );
#endif
      return desc;
    }

    std::string Exception::filename( ) const noexcept
    {
      return exceptionFilename;
    }

    void Exception::filename( std::string const& fname ) noexcept
    {
      exceptionFilename = fname;
    }

    unsigned long Exception::lineNumber( ) const noexcept
    {
      return exceptionLineNumber;
    }

    void Exception::lineNumber( unsigned long lineno ) noexcept
    {
      exceptionLineNumber = lineno;
    }

  }  // namespace exception
}  // namespace fedem