2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
2009-09-13 20:56:22 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-02-09 21:15:56 +00:00
|
|
|
*/
|
|
|
|
|
2009-04-07 21:54:50 +00:00
|
|
|
#pragma once
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
#include "Dependencies.h"
|
|
|
|
|
|
|
|
extern void DevAssert( bool condition, const char* msg );
|
|
|
|
|
2009-09-13 17:11:35 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// DESTRUCTOR_CATCHALL - safe destructor helper
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// In C++ destructors *really* need to be "nothrow" garaunteed, otherwise you can have
|
|
|
|
// disasterous nested exception throws during the unwinding process of an originating
|
|
|
|
// exception. Use this macro to dispose of these dangerous exceptions, and generate a
|
|
|
|
// friendly error log in their wake.
|
|
|
|
//
|
2009-09-13 20:56:22 +00:00
|
|
|
#define __DESTRUCTOR_CATCHALL( funcname ) \
|
2009-09-13 17:11:35 +00:00
|
|
|
catch( Exception::BaseException& ex ) \
|
|
|
|
{ \
|
2009-09-13 20:56:22 +00:00
|
|
|
Console::Error( "Unhandled BaseException in %s (ignored!):", funcname ); \
|
2009-09-13 17:11:35 +00:00
|
|
|
Console::Error( ex.FormatDiagnosticMessage() ); \
|
|
|
|
} \
|
|
|
|
catch( std::exception& ex ) \
|
|
|
|
{ \
|
2009-09-13 20:56:22 +00:00
|
|
|
Console::Error( "Unhandled std::exception in %s (ignored!):", funcname ); \
|
2009-09-13 17:11:35 +00:00
|
|
|
Console::Error( ex.what() ); \
|
2009-09-13 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
# define DESTRUCTOR_CATCHALL __DESTRUCTOR_CATCHALL( __PRETTY_FUNCTION__ )
|
|
|
|
#else
|
|
|
|
# define DESTRUCTOR_CATCHALL __DESTRUCTOR_CATCHALL( __FUNCTION__ )
|
|
|
|
#endif
|
2009-09-13 17:11:35 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
namespace Exception
|
|
|
|
{
|
2009-09-13 17:11:35 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// BaseException
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-04-27 02:04:31 +00:00
|
|
|
// std::exception sucks, and isn't entirely cross-platform reliable in its implementation,
|
2009-09-01 00:43:28 +00:00
|
|
|
// so I made a replacement. The internal messages are non-const, which means that a
|
|
|
|
// catch clause can optionally modify them and then re-throw to a top-level handler.
|
2009-04-27 02:04:31 +00:00
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
// Note, this class is "abstract" which means you shouldn't use it directly like, ever.
|
2009-04-27 02:04:31 +00:00
|
|
|
// Use Exception::RuntimeError or Exception::LogicError instead for generic exceptions.
|
|
|
|
//
|
2009-09-01 00:43:28 +00:00
|
|
|
// Because exceptions are the (only!) really useful example of multiple inheritance,
|
|
|
|
// this class has only a trivial constructor, and must be manually initialized using
|
|
|
|
// InitBaseEx() or by individual member assignments. This is because C++ multiple inheritence
|
|
|
|
// is, by design, a lot of fail, especially when class initializers are mixed in.
|
|
|
|
//
|
|
|
|
// [TODO] : Add an InnerException component, and Clone() facility.
|
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
class BaseException
|
|
|
|
{
|
|
|
|
protected:
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred!
|
|
|
|
wxString m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred!
|
|
|
|
wxString m_stacktrace; // contains the stack trace string dump (unimplemented)
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~BaseException() throw()=0; // the =0; syntax forces this class into "abstract" mode.
|
2009-04-27 02:04:31 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
const wxString& DiagMsg() const { return m_message_diag; }
|
|
|
|
const wxString& UserMsg() const { return m_message_user; }
|
|
|
|
|
|
|
|
wxString& DiagMsg() { return m_message_diag; }
|
|
|
|
wxString& UserMsg() { return m_message_user; }
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
// Returns a message suitable for diagnostic / logging purposes.
|
2009-09-01 00:43:28 +00:00
|
|
|
// This message is always in English, and includes a full stack trace.
|
|
|
|
virtual wxString FormatDiagnosticMessage() const;
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
// Returns a message suitable for end-user display.
|
|
|
|
// This message is usually meant for display in a user popup or such.
|
2009-09-01 00:43:28 +00:00
|
|
|
virtual wxString FormatDisplayMessage() const { return m_message_user; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Construction using two pre-formatted pre-translated messages
|
|
|
|
void InitBaseEx( const wxString& msg_eng, const wxString& msg_xlt );
|
|
|
|
|
|
|
|
// Construction using one translation key.
|
|
|
|
void InitBaseEx( const char* msg_eng );
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
2009-09-13 20:56:22 +00:00
|
|
|
|
2009-09-13 17:11:35 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// Ps2Generic Exception
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-03-01 21:49:17 +00:00
|
|
|
// This class is used as a base exception for things tossed by PS2 cpus (EE, IOP, etc).
|
2009-09-01 00:43:28 +00:00
|
|
|
//
|
|
|
|
// Implementation note: does not derive from BaseException, so that we can use different
|
|
|
|
// catch block hierarchies to handle them (if needed).
|
|
|
|
//
|
|
|
|
// Translation Note: Currently these exceptions are never translated. English/diagnostic
|
|
|
|
// format only. :)
|
2009-04-27 02:04:31 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class Ps2Generic
|
2009-03-01 21:49:17 +00:00
|
|
|
{
|
2009-08-31 03:47:05 +00:00
|
|
|
protected:
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString m_message; // a "detailed" message of what disastrous thing has occurred!
|
2009-08-31 03:47:05 +00:00
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
public:
|
|
|
|
virtual ~Ps2Generic() throw() {}
|
|
|
|
|
|
|
|
virtual u32 GetPc() const=0;
|
|
|
|
virtual bool IsDelaySlot() const=0;
|
2009-09-01 00:43:28 +00:00
|
|
|
virtual wxString Message() const { return m_message; }
|
2009-03-01 21:49:17 +00:00
|
|
|
};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
// Some helper macros for defining the standard constructors of internationalized constructors
|
|
|
|
// Parameters:
|
|
|
|
// classname - Yeah, the name of this class being defined. :)
|
|
|
|
//
|
|
|
|
// defmsg - default message (in english), which will be used for both english and i18n messages.
|
|
|
|
// The text string will be passed through the translator, so if it's int he gettext database
|
|
|
|
// it will be optionally translated.
|
|
|
|
//
|
|
|
|
#define DEFINE_EXCEPTION_COPYTORS( classname ) \
|
|
|
|
virtual ~classname() throw() {}
|
|
|
|
|
|
|
|
#define DEFINE_RUNTIME_EXCEPTION( classname, defmsg ) \
|
|
|
|
DEFINE_EXCEPTION_COPYTORS( classname ) \
|
|
|
|
\
|
|
|
|
explicit classname( const char* msg=defmsg ) { BaseException::InitBaseEx( msg ); } \
|
|
|
|
explicit classname( const wxString& msg_eng, const wxString& msg_xlt ) { BaseException::InitBaseEx( msg_eng, msg_xlt); }
|
|
|
|
|
|
|
|
#define DEFINE_LOGIC_EXCEPTION( classname, defmsg ) \
|
|
|
|
DEFINE_EXCEPTION_COPYTORS( classname ) \
|
|
|
|
\
|
|
|
|
explicit classname( const char* msg=defmsg ) { BaseException::InitBaseEx( msg ); } \
|
|
|
|
explicit classname( const wxString& msg_eng ) { BaseException::InitBaseEx( msg_eng, wxEmptyString ); }
|
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
2009-09-18 14:07:36 +00:00
|
|
|
// Generalized Exceptions: RuntimeError / LogicError / ObjectIsNull
|
2009-07-14 06:18:52 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
class RuntimeError : public virtual BaseException
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_RUNTIME_EXCEPTION( RuntimeError, wxLt("An unhandled runtime error has occurred, somewhere in the depths of Pcsx2's cluttered brain-matter.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
// LogicErrors do not need translated versions, since they are typically obscure, and the
|
|
|
|
// user wouldn't benefit from being able to understand them anyway. :)
|
2009-08-31 03:47:05 +00:00
|
|
|
class LogicError : public virtual BaseException
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_LOGIC_EXCEPTION( LogicError, wxLt("An unhandled logic error has occurred.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
2009-08-31 03:47:05 +00:00
|
|
|
|
2009-09-18 14:07:36 +00:00
|
|
|
class ObjectIsNull : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxString ObjectName;
|
|
|
|
|
|
|
|
DEFINE_EXCEPTION_COPYTORS( ObjectIsNull )
|
|
|
|
|
|
|
|
explicit ObjectIsNull( const char* objname="unspecified" )
|
|
|
|
{
|
|
|
|
m_message_diag = wxString::FromUTF8( objname );
|
|
|
|
// overridden message formatters only use the diagnostic version...
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual wxString FormatDisplayMessage() const;
|
|
|
|
virtual wxString FormatDiagnosticMessage() const;
|
|
|
|
};
|
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// OutOfMemory / InvalidOperation / InvalidArgument / IndexBoundsFault / ParseError
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
class OutOfMemory : public virtual RuntimeError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_RUNTIME_EXCEPTION( OutOfMemory, wxLt("Out of Memory") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This exception thrown any time an operation is attempted when an object
|
|
|
|
// is in an uninitialized state.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class InvalidOperation : public virtual LogicError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_LOGIC_EXCEPTION( InvalidOperation, "Attempted method call is invalid for the current object or program state." )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This exception thrown any time an operation is attempted when an object
|
|
|
|
// is in an uninitialized state.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class InvalidArgument : public virtual LogicError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_LOGIC_EXCEPTION( InvalidArgument, "Invalid argument passed to a function." )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Keep those array indexers in bounds when using the SafeArray type, or you'll be
|
|
|
|
// seeing these.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-09-01 00:43:28 +00:00
|
|
|
class IndexBoundsFault : public virtual LogicError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-04-27 02:04:31 +00:00
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
wxString ArrayName;
|
|
|
|
int ArrayLength;
|
|
|
|
int BadIndex;
|
2009-04-27 02:04:31 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_EXCEPTION_COPYTORS( IndexBoundsFault )
|
2009-09-13 20:56:22 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
IndexBoundsFault( const wxString& objname, int index, int arrsize )
|
|
|
|
{
|
|
|
|
BaseException::InitBaseEx( "Index is outside the bounds of an array." );
|
|
|
|
|
|
|
|
ArrayName = objname;
|
|
|
|
ArrayLength = arrsize;
|
|
|
|
BadIndex = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString FormatDiagnosticMessage() const;
|
|
|
|
virtual wxString FormatDisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
2009-09-13 20:56:22 +00:00
|
|
|
|
2009-04-02 11:30:23 +00:00
|
|
|
class ParseError : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_RUNTIME_EXCEPTION( ParseError, "Parse error" );
|
2009-09-13 20:56:22 +00:00
|
|
|
};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// Hardware/OS Exceptions:
|
|
|
|
// HardwareDeficiency / CpuStateShutdown / PluginFailure / ThreadCreationError
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
class HardwareDeficiency : public virtual RuntimeError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_RUNTIME_EXCEPTION( HardwareDeficiency, wxLt("Your machine's hardware is incapable of running Pcsx2. Sorry dood.") );
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
class ThreadCreationError : public virtual RuntimeError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_RUNTIME_EXCEPTION( ThreadCreationError, wxLt("Thread could not be created.") );
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// Streaming (file) Exceptions:
|
|
|
|
// Stream / BadStream / CreateStream / FileNotFound / AccessDenied / EndOfStream
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
#define DEFINE_STREAM_EXCEPTION( classname, defmsg ) \
|
|
|
|
DEFINE_EXCEPTION_COPYTORS( classname ) \
|
|
|
|
\
|
|
|
|
explicit classname( const wxString& objname=wxString(), const char* msg=defmsg ) \
|
|
|
|
{ \
|
|
|
|
BaseException::InitBaseEx( msg ); \
|
|
|
|
StreamName = objname; \
|
|
|
|
} \
|
|
|
|
explicit classname( const wxString& objname, const wxString& msg_eng, const wxString& msg_xlt ) \
|
|
|
|
{ \
|
|
|
|
BaseException::InitBaseEx( msg_eng, msg_xlt ); \
|
|
|
|
StreamName = objname; \
|
|
|
|
} \
|
|
|
|
explicit classname( const char* objname, const char* msg=defmsg ) \
|
|
|
|
{ \
|
|
|
|
BaseException::InitBaseEx( msg ); \
|
|
|
|
StreamName = wxString::FromUTF8( objname ); \
|
|
|
|
} \
|
|
|
|
explicit classname( const char* objname, const wxString& msg_eng, const wxString& msg_xlt ) \
|
|
|
|
{ \
|
|
|
|
BaseException::InitBaseEx( msg_eng, msg_xlt ); \
|
|
|
|
StreamName = wxString::FromUTF8( objname ); \
|
|
|
|
} \
|
|
|
|
explicit classname( const char* objname, const wxString& msg_eng ) \
|
|
|
|
{ \
|
|
|
|
BaseException::InitBaseEx( msg_eng, msg_eng ); \
|
|
|
|
StreamName = wxString::FromUTF8( objname ); \
|
|
|
|
} \
|
|
|
|
explicit classname( const wxString& objname, const wxString& msg_eng ) \
|
|
|
|
{ \
|
|
|
|
BaseException::InitBaseEx( msg_eng, msg_eng ); \
|
|
|
|
StreamName = objname; \
|
|
|
|
}
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
// Generic stream error. Contains the name of the stream and a message.
|
2009-07-14 06:18:52 +00:00
|
|
|
// This exception is usually thrown via derived classes, except in the (rare) case of a
|
|
|
|
// generic / unknown error.
|
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class Stream : public virtual RuntimeError
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-04-27 02:04:31 +00:00
|
|
|
wxString StreamName; // name of the stream (if applicable)
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
public:
|
|
|
|
DEFINE_STREAM_EXCEPTION( Stream, "General file operation error." )
|
|
|
|
|
|
|
|
virtual wxString FormatDiagnosticMessage() const;
|
|
|
|
virtual wxString FormatDisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A generic base error class for bad streams -- corrupted data, sudden closures, loss of
|
|
|
|
// connection, or anything else that would indicate a failure to read the data after the
|
|
|
|
// stream was successfully opened.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class BadStream : public virtual Stream
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 17:23:02 +00:00
|
|
|
DEFINE_STREAM_EXCEPTION( BadStream, wxLt("File data is corrupted or incomplete, or the stream connection closed unexpectedly.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A generic exception for odd-ball stream creation errors.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class CreateStream : public virtual Stream
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 17:23:02 +00:00
|
|
|
DEFINE_STREAM_EXCEPTION( CreateStream, wxLt("File could not be created or opened.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Exception thrown when an attempt to open a non-existent file is made.
|
|
|
|
// (this exception can also mean file permissions are invalid)
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class FileNotFound : public virtual CreateStream
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 17:23:02 +00:00
|
|
|
DEFINE_STREAM_EXCEPTION( FileNotFound, wxLt("File not found.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-08-31 03:47:05 +00:00
|
|
|
class AccessDenied : public virtual CreateStream
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 17:23:02 +00:00
|
|
|
DEFINE_STREAM_EXCEPTION( AccessDenied, wxLt("Permission denied to file.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
// EndOfStream can be used either as an error, or used just as a shortcut for manual
|
|
|
|
// feof checks.
|
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class EndOfStream : public virtual Stream
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 17:23:02 +00:00
|
|
|
DEFINE_STREAM_EXCEPTION( EndOfStream, wxLt("Unexpected end of file or stream.") );
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
// Savestate Exceptions:
|
|
|
|
// BadSavedState / FreezePluginFailure / StateLoadError / UnsupportedStateVersion /
|
|
|
|
// StateCrcMismatch
|
|
|
|
// ---------------------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// Exception thrown when a corrupted or truncated savestate is encountered.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class BadSavedState : public virtual BadStream
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 17:23:02 +00:00
|
|
|
DEFINE_STREAM_EXCEPTION( BadSavedState, wxLt("Savestate data is corrupted or incomplete.") )
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
// thrown when the savestate being loaded isn't supported.
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class UnsupportedStateVersion : public virtual BadSavedState
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
u32 Version; // version number of the unsupported state.
|
|
|
|
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_EXCEPTION_COPYTORS( UnsupportedStateVersion )
|
2009-09-13 20:56:22 +00:00
|
|
|
|
2009-09-01 00:43:28 +00:00
|
|
|
explicit UnsupportedStateVersion( int version, const wxString& objname=wxEmptyString )
|
|
|
|
{
|
|
|
|
StreamName = objname;
|
|
|
|
Version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString FormatDiagnosticMessage() const;
|
|
|
|
virtual wxString FormatDisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// A recoverable exception thrown when the CRC of the savestate does not match the
|
|
|
|
// CRC returned by the Cdvd driver.
|
2009-03-01 21:49:17 +00:00
|
|
|
// [feature not implemented yet]
|
2009-07-14 06:18:52 +00:00
|
|
|
//
|
2009-08-31 03:47:05 +00:00
|
|
|
class StateCrcMismatch : public virtual BadSavedState
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
u32 Crc_Savestate;
|
|
|
|
u32 Crc_Cdvd;
|
|
|
|
|
|
|
|
public:
|
2009-09-01 00:43:28 +00:00
|
|
|
DEFINE_EXCEPTION_COPYTORS( StateCrcMismatch )
|
|
|
|
|
|
|
|
explicit StateCrcMismatch( u32 crc_save, u32 crc_cdvd, const wxString& objname=wxEmptyString )
|
|
|
|
{
|
|
|
|
StreamName = objname;
|
|
|
|
Crc_Savestate = crc_save;
|
|
|
|
Crc_Cdvd = crc_cdvd;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString FormatDiagnosticMessage() const;
|
|
|
|
virtual wxString FormatDisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
}
|