I have a function with following code:
if (!File::exists(i_filename)) throw new FileNotFoundException(i_filename);
My FileNotFoundException looks like this .h
#pragma once
#include <exception>
#include <string>
class FileNotFoundException : public std::exception {
public:
FileNotFoundException(const std::string &i_filename);
private:
std::string m_filename;
};
.cpp
#include "FileNotFoundException.h"
FileNotFoundException::FileNotFoundException(const std::string & i_filename) {
m_filename = i_filename;
// A message will be pushed to console & debug window, I first wanted to test
}
But Visual Studio tells me Unhandled Exception at 0x7432D8A8 in 2D Game.exe: Microsoft C++ Exception: FileNotFoundException at storage location 0x0018F5FC.
when I run throw new FileNotFoundException(i_filename);
Does anyone know what's wrong? Sorry, but I have never created an exception class before.