mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Make love::Exception safe(r).
Now allows exceptions of arbitrary length. Now allows catching a non-reference, i.e. catch(love::Exception e).
This commit is contained in:
+5
-11
@@ -25,6 +25,7 @@
|
||||
#include <cstdarg> // vararg
|
||||
#include <cstdio> // vsnprintf
|
||||
#include <cstring> // strncpy
|
||||
#include <string>
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -35,15 +36,7 @@ namespace love
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* The vsnprintf operates on a buffer this large.
|
||||
**/
|
||||
static const int BUFFER_SIZE = 256;
|
||||
|
||||
/**
|
||||
* The buffer for vsnprintf.
|
||||
**/
|
||||
char buffer[BUFFER_SIZE];
|
||||
std::string message;
|
||||
|
||||
public:
|
||||
|
||||
@@ -55,13 +48,14 @@ namespace love
|
||||
* @param fmt The format string (see printf).
|
||||
**/
|
||||
Exception(const char * fmt, ...);
|
||||
Exception(int unparsed, const char * str);
|
||||
virtual ~Exception() throw() {}
|
||||
|
||||
/**
|
||||
* Returns a string containing reason for the exception.
|
||||
* @return A description of the exception.
|
||||
**/
|
||||
virtual const char * what() const throw();
|
||||
inline virtual const char * what() const throw()
|
||||
{ return message.c_str(); }
|
||||
|
||||
}; // class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user