/*
* Author:          Patrick-Christopher Mattulat
* Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-02-22
* Changed:         2026-06-23
*
* */

#include <ls-std/core/exception/Exception.hpp>
#include <ls-std/core/exception/ExceptionMessage.hpp>

using ls::standard::core::Exception;
using std::move;
using std::string;
using std::string_view;

Exception::Exception(string _name) : name(::move(_name))
{}

Exception::~Exception() noexcept = default;

string Exception::getName() const
{
  return this->name;
}

const char *Exception::_getIdentifiedMessage(const string &_defaultMessage) const
{
  string concatenatedMessage = this->name + " thrown - ";

  if (this->message.empty())
  {
    concatenatedMessage = concatenatedMessage + _defaultMessage;
  }
  else
  {
    concatenatedMessage = concatenatedMessage + this->message;
  }

  return ExceptionMessage{concatenatedMessage}.toCharacterPointer();
}

void Exception::_setMessage(const string_view _message)
{
  this->message = _message;
}
