Files
AdventuresInLestoria/Crawler/Error.h
T

37 lines
893 B
C++

#pragma once
#include <ostream>
#ifndef __EMSCRIPTEN__
#include <source_location>
#endif
#ifdef _DEBUG
#define NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
// Replace _NORMAL_BLOCK with _CLIENT_BLOCK if you want the
// allocations to be of _CLIENT_BLOCK type
#else
#define NEW new
#endif
#undef ERR //Stupid Windows
#ifndef __EMSCRIPTEN__
#define ERR(err) { \
std::stringstream errStream; \
errStream<<err; \
Error::log(errStream,std::source_location::current());}
class Error{
public:
inline static void log(std::stringstream&str,std::source_location loc){
std::cout<<loc.file_name()<<"("<<loc.line()<<":"<<loc.column()<<") "<<loc.function_name()<<": "<<str.str()<<std::endl;
throw;
}
};
#else
#define ERR(err) { \
std::stringstream errStream; \
errStream<<err; \
std::cout<<errStream.str(); }
#define _CrtDumpMemoryLeaks() ((int)0)
#endif