00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "../include/base.h"
00023 #include <iostream>
00024 #include <signal.h>
00025 #include "../tool/i18n.h"
00026
00027 #if !defined WIN32 || defined __MINGW32__
00028 #include <sys/types.h>
00029 #include <unistd.h>
00030 #endif
00031
00032 void WakeUpDebugger()
00033 {
00034
00035 #ifdef LOVE_HAYPO_HACKS
00036
00037 asm ("int $0x03");
00038 #endif
00039
00040 #if !defined WIN32
00041 kill (getpid(), SIGABRT);
00042 #endif
00043 }
00044
00045 void MissedAssertion (const char *filename, unsigned long line,
00046 const char *message)
00047 {
00048 std::cout << std::endl;
00049 std::cerr << filename << ':' << line
00050 << ": Missed assertion \"" << message << "\"."
00051 << std::endl;
00052 #if defined DEBUG
00053 WakeUpDebugger();
00054 abort();
00055 #endif
00056 }
00057
00058 CError::CError (const char *filename, unsigned long line,
00059 const std::string &txt)
00060 : m_filename(filename), m_txt(txt), m_line(line)
00061 {}
00062
00063 CError::~CError() throw()
00064 {}
00065
00066 const char* CError::what() const throw()
00067 {
00068 return m_txt.c_str();
00069 }
00070
00071 std::ostream& CError::operator<< (std::ostream &os) const
00072 {
00073 os << m_txt;
00074 return os;
00075 }
00076
00077 void TriggerError (const char *filename, unsigned long line,
00078 const std::string &txt)
00079 {
00080 std::cout << "! "
00081 << Format(_("Error in %s:%lu"), filename, line)
00082 << ": " << txt << std::endl;
00083
00084 assert(false);
00085 throw CError (filename, line, txt);
00086 }