Some exception cleanup

This commit is contained in:
Bart van Strien
2011-09-11 22:55:34 +02:00
parent 8f9a4ef15d
commit dc873c24f0
4 changed files with 12 additions and 25 deletions
+5
View File
@@ -30,6 +30,11 @@ namespace love
va_end(args);
}
Exception::Exception(int unparsed, const char * str)
{
strncpy(buffer, str, BUFFER_SIZE);
}
const char * Exception::what() const throw()
{
return (const char *)buffer;
+2
View File
@@ -24,6 +24,7 @@
#include <exception>
#include <cstdarg> // vararg
#include <cstdio> // vsnprintf
#include <cstring> // strncpy
namespace love
{
@@ -54,6 +55,7 @@ namespace love
* @param fmt The format string (see printf).
**/
Exception(const char * fmt, ...);
Exception(int unparsed, const char * str);
/**
* Returns a string containing reason for the exception.
+4 -24
View File
@@ -174,20 +174,10 @@ namespace opengl
dx += glyph->spacing;
}
}
catch (utf8::invalid_code_point e)
catch (utf8::exception & e)
{
glPopMatrix();
throw love::Exception(e.what());
}
catch (utf8::invalid_utf8 e)
{
glPopMatrix();
throw love::Exception(e.what());
}
catch (utf8::exception e)
{
glPopMatrix();
throw love::Exception(e.what());
throw love::Exception(1, e.what());
}
glPopMatrix();
}
@@ -220,19 +210,9 @@ namespace opengl
temp += static_cast<int>(g->spacing * mSpacing);
}
}
catch (utf8::invalid_code_point e)
catch (utf8::exception & e)
{
glPopMatrix();
throw love::Exception(e.what());
}
catch (utf8::invalid_utf8 e)
{
glPopMatrix();
throw love::Exception(e.what());
}
catch (utf8::exception e)
{
throw love::Exception(e.what());
throw love::Exception(1, e.what());
}
return temp;
@@ -25,7 +25,7 @@
#define B2_NOT_USED(x) x
//#define b2Assert(A) assert(A)
#define b2Assert(A) {if(!(A)) throw love::Exception(#A);}
#define b2Assert(A) {if(!(A)) throw love::Exception(1, #A);}
// need to include NDS jtypes.h instead of