exceptions.hpp

This commit is contained in:
Timerix 2024-08-01 20:43:45 +03:00
parent 22c64c9e9b
commit 7471c09452
4 changed files with 31 additions and 15 deletions

View File

@ -2,7 +2,7 @@
#include <backends/imgui_impl_opengl3.h>
#include <iostream>
#include "MainWindow.hpp"
#include "exceptions.hpp"
#include "../exceptions.hpp"
#include "../format.hpp"
#include "../Resources/fonts.hpp"

View File

@ -1,12 +0,0 @@
#include "exceptions.hpp"
#include <SDL.h>
namespace ougge::GUI {
SDLException_::SDLException_(const std::string& _file,const std::string& _func, int _line_n)
: UsefulException_(SDL_GetError(), _file, _func, _line_n)
{
SDL_ClearError();
}
}

19
src/exceptions.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "exceptions.hpp"
#include <SDL.h>
#include <SDL_image.h>
namespace ougge {
SDLException_::SDLException_(const std::string& _file,const std::string& _func, int _line_n)
: UsefulException_(std::string("SDLException: ") + SDL_GetError(), _file, _func, _line_n)
{
SDL_ClearError();
}
IMGException_::IMGException_(const std::string& _file,const std::string& _func, int _line_n)
: UsefulException_(std::string("IMGException: ") + IMG_GetError(), _file, _func, _line_n)
{
SDL_ClearError();
}
}

View File

@ -1,8 +1,8 @@
#pragma once
#include "../UsefulException.hpp"
#include "UsefulException.hpp"
namespace ougge::GUI {
namespace ougge {
#define SDLException() SDLException_(__FILE__, __func__, __LINE__)
@ -11,6 +11,15 @@ public:
SDLException_(const std::string& _file, const std::string& _func, int line_n);
};
#define IMGException() IMGException_(__FILE__, __func__, __LINE__)
class IMGException_ : public UsefulException_ {
public:
IMGException_(const std::string& _file, const std::string& _func, int line_n);
};
#define SDL_TRY(EXPR) if(EXPR) throw SDLException();
}