Browse Source

Some exception cleanup

Bart van Strien 14 years ago
parent
commit
dc873c24f0

+ 5 - 0
src/common/Exception.cpp

@@ -30,6 +30,11 @@ namespace love
 		va_end(args);
 		va_end(args);
 	}
 	}
 
 
+	Exception::Exception(int unparsed, const char * str)
+	{
+		strncpy(buffer, str, BUFFER_SIZE);
+	}
+
 	const char * Exception::what() const throw()
 	const char * Exception::what() const throw()
 	{
 	{
 		return (const char *)buffer;
 		return (const char *)buffer;

+ 2 - 0
src/common/Exception.h

@@ -24,6 +24,7 @@
 #include <exception>
 #include <exception>
 #include <cstdarg> // vararg
 #include <cstdarg> // vararg
 #include <cstdio> // vsnprintf
 #include <cstdio> // vsnprintf
+#include <cstring> // strncpy
 
 
 namespace love
 namespace love
 {
 {
@@ -54,6 +55,7 @@ namespace love
 		* @param fmt The format string (see printf).
 		* @param fmt The format string (see printf).
 		**/
 		**/
 		Exception(const char * fmt, ...);
 		Exception(const char * fmt, ...);
+		Exception(int unparsed, const char * str);
 
 
 		/**
 		/**
 		* Returns a string containing reason for the exception.
 		* Returns a string containing reason for the exception.

+ 4 - 24
src/modules/graphics/opengl/Font.cpp

@@ -174,20 +174,10 @@ namespace opengl
 				dx += glyph->spacing;
 				dx += glyph->spacing;
 			}
 			}
 		}
 		}
-		catch (utf8::invalid_code_point e)
+		catch (utf8::exception & e)
 		{
 		{
 			glPopMatrix();
 			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();
 		glPopMatrix();
 	}
 	}
@@ -220,19 +210,9 @@ namespace opengl
 				temp += static_cast<int>(g->spacing * mSpacing);
 				temp += static_cast<int>(g->spacing * mSpacing);
 			}
 			}
 		}
 		}
-		catch (utf8::invalid_code_point e)
-		{
-			glPopMatrix();
-			throw love::Exception(e.what());
-		}
-		catch (utf8::invalid_utf8 e)
-		{
-			glPopMatrix();
-			throw love::Exception(e.what());
-		}
-		catch (utf8::exception e)
+		catch (utf8::exception & e)
 		{
 		{
-			throw love::Exception(e.what());
+			throw love::Exception(1, e.what());
 		}
 		}
 
 
 		return temp;
 		return temp;

+ 1 - 1
src/modules/physics/box2d/Source/Common/b2Settings.h

@@ -25,7 +25,7 @@
 
 
 #define B2_NOT_USED(x) x
 #define B2_NOT_USED(x) x
 //#define b2Assert(A) assert(A)
 //#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
 // need to include NDS jtypes.h instead of