Napisałem własny wyjątek
#pragma once
#include <exception>
#include <string>
class TextureLoadException : public std::exception
{
const std::string EX_MESSAGE = "Couldn't open texture file: ";
std::string error_source;
public:
virtual const char * what() const throw();
TextureLoadException(std::string _error_source);
~TextureLoadException();
};
const char * TextureLoadException::what() const throw()
{
return (EX_MESSAGE + error_source).c_str();
}
TextureLoadException::TextureLoadException(std::string _error_source) : error_source(_error_source)
{
}
TextureLoadException::~TextureLoadException()
{
}
i łapię go przez catch(std::exception& ex)
, jednakże po wypisaniu przez what() dostaję ciąg dziwnych znaków. Dlaczego tak się dzieje?