Code View

// SPDX-License-Identifier: MIT
// Like plugin's dso/Exception.hh: an exported base whose what() calls a pure
// virtual text method the generated exceptions override.
#pragma once

#include <exception>
#include <string>

#define LIB_EXPORT __attribute__( ( visibility( "default" ) ) )

namespace lib
{
  class LIB_EXPORT Base
    : public std::exception
  {
    public:
      virtual std::string whatStr( ) const noexcept = 0;

      char const *what( ) const noexcept override
      {
        text = whatStr( );
        return text.c_str( );
      }

    private:
      mutable std::string text;
  };
}