2009-02-09 21:15:56 +00:00
|
|
|
/* Pcsx2 - Pc Ps2 Emulator
|
2009-02-15 23:23:46 +00:00
|
|
|
* Copyright (C) 2002-2009 Pcsx2 Team
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
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-04-27 02:04:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
2009-02-09 21:15:56 +00:00
|
|
|
// This class provides an easy and clean method for ensuring objects are not copyable.
|
|
|
|
class NoncopyableObject
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
NoncopyableObject() {}
|
|
|
|
~NoncopyableObject() {}
|
|
|
|
|
|
|
|
// Programmer's note:
|
|
|
|
// No need to provide implementations for these methods since they should
|
|
|
|
// never be referenced anyway. No references? No Linker Errors! Noncopyable!
|
|
|
|
private:
|
|
|
|
// Copy me? I think not!
|
|
|
|
explicit NoncopyableObject( const NoncopyableObject& );
|
|
|
|
// Assign me? I think not!
|
|
|
|
const NoncopyableObject& operator=( const NoncopyableObject& );
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
2009-02-09 21:15:56 +00:00
|
|
|
// Base class used to implement type-safe sealed classes.
|
2009-04-27 02:04:31 +00:00
|
|
|
// This class should never be used directly. Use the Sealed macro instead, which ensures
|
|
|
|
// all sealed classes derive from a unique BaseSealed (preventing them from accidentally
|
|
|
|
// circumventing sealing by inheriting from multiple sealed classes.
|
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
template < int T >
|
|
|
|
class __BaseSealed
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
__BaseSealed()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// Use this macro/class as a base to seal a class from being derived from.
|
2009-02-09 21:15:56 +00:00
|
|
|
// This macro works by providing a unique base class with a protected constructor
|
|
|
|
// for every class that derives from it.
|
|
|
|
#define Sealed private virtual __BaseSealed<__COUNTER__>
|
|
|
|
|
|
|
|
namespace Exception
|
|
|
|
{
|
2009-03-01 21:49:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
2009-04-27 02:04:31 +00:00
|
|
|
// std::exception sucks, and isn't entirely cross-platform reliable in its implementation,
|
|
|
|
// so I made a replacement.
|
|
|
|
//
|
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-02-09 21:15:56 +00:00
|
|
|
class BaseException
|
|
|
|
{
|
|
|
|
protected:
|
2009-04-27 02:04:31 +00:00
|
|
|
const wxString m_message_eng; // (untranslated) a "detailed" message of what disastrous thing has occurred!
|
|
|
|
const wxString m_message; // (translated) a "detailed" message of what disastrous thing has occurred!
|
|
|
|
const 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
|
|
|
|
|
|
|
// copy construct
|
|
|
|
BaseException( const BaseException& src ) :
|
|
|
|
m_message_eng( src.m_message_eng ),
|
|
|
|
m_message( src.m_message ),
|
|
|
|
m_stacktrace( src.m_stacktrace ) { }
|
|
|
|
|
|
|
|
// Contruction using two pre-formatted pre-translated messages
|
|
|
|
BaseException( const wxString& msg_eng, const wxString& msg_xlt );
|
2009-03-22 11:01:35 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// Construction using one translation key.
|
|
|
|
explicit BaseException( const char* msg_eng );
|
|
|
|
|
|
|
|
// Returns a message suitable for diagnostic / logging purposes.
|
|
|
|
// This message is always in english, and includes a full stack trace.
|
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
|
|
|
|
// Returns a message suitable for end-user display.
|
|
|
|
// This message is usually meant for display in a user popup or such.
|
|
|
|
virtual wxString DisplayMessage() const { return m_message; }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
2009-03-01 21:49:17 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
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-04-27 02:04:31 +00:00
|
|
|
// Translation Note: These exceptions are never translated, except to issue a general
|
2009-07-03 00:49:40 +00:00
|
|
|
// error message to the user (which is specified below).
|
2009-04-27 02:04:31 +00:00
|
|
|
//
|
2009-03-01 21:49:17 +00:00
|
|
|
class Ps2Generic : public BaseException
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Ps2Generic() throw() {}
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit Ps2Generic( const char* msg="Ps2/MIPS cpu caused a general exception" ) :
|
|
|
|
BaseException( msg ) { }
|
|
|
|
explicit Ps2Generic( const wxString& msg_eng, const wxString& msg_xlt=_("Ps2/MIPS cpu caused a general exception") ) :
|
|
|
|
BaseException( msg_eng, msg_xlt ) { }
|
2009-03-01 21:49:17 +00:00
|
|
|
|
|
|
|
virtual u32 GetPc() const=0;
|
|
|
|
virtual bool IsDelaySlot() const=0;
|
|
|
|
};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
class RuntimeError : public BaseException
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~RuntimeError() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
RuntimeError( const RuntimeError& src ) : BaseException( src ) {}
|
|
|
|
|
|
|
|
explicit RuntimeError( const char* msg="An unhandled runtime error has occurred, somewhere in the depths of Pcsx2's cluttered brain-matter." ) :
|
|
|
|
BaseException( msg ) { }
|
|
|
|
|
|
|
|
explicit RuntimeError( const wxString& msg_eng, const wxString& msg_xlt ) :
|
|
|
|
BaseException( msg_eng, msg_xlt ) { }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
class LogicError : public BaseException
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~LogicError() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
LogicError( const LogicError& src ) : BaseException( src ) {}
|
|
|
|
|
|
|
|
explicit LogicError( const char* msg="An unhandled logic error has occurred." ) :
|
|
|
|
BaseException( msg ) { }
|
|
|
|
|
|
|
|
explicit LogicError( const wxString& msg_eng, const wxString& msg_xlt ) :
|
|
|
|
BaseException( msg_eng, msg_xlt ) { }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-07-03 00:49:40 +00:00
|
|
|
class AssertionFailure : public LogicError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AssertionFailure( const char* msg="Assertion Failure" ) :
|
|
|
|
LogicError( msg ) {}
|
|
|
|
|
|
|
|
explicit AssertionFailure( const wxString& msg_eng, const wxString& msg_xlt ) :
|
|
|
|
LogicError( msg_eng, msg_xlt ) { }
|
|
|
|
|
|
|
|
virtual ~AssertionFailure() throw() {}
|
|
|
|
};
|
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
class OutOfMemory : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
2009-03-04 13:00:32 +00:00
|
|
|
virtual ~OutOfMemory() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit OutOfMemory( const char* msg="Out of memory" ) :
|
|
|
|
RuntimeError( msg ) {}
|
|
|
|
|
|
|
|
explicit OutOfMemory( const wxString& msg_eng, const wxString& msg_xlt=_("Out of memory") ) :
|
|
|
|
RuntimeError( msg_eng, msg_xlt ) { }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
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.
|
|
|
|
class InvalidOperation : public LogicError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~InvalidOperation() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit InvalidOperation( const char* msg="Attempted method call is invalid for the current object or program state." ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
LogicError( msg ) {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
explicit InvalidOperation( const wxString& msg_eng, const wxString& msg_xlt ) :
|
|
|
|
LogicError( msg_eng, msg_xlt ) { }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
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.
|
|
|
|
class InvalidArgument : public LogicError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~InvalidArgument() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit InvalidArgument( const char* msg="Invalid argument passed to a function." ) :
|
|
|
|
LogicError( msg )
|
|
|
|
{
|
|
|
|
// assertions make debugging easier sometimes. :)
|
|
|
|
wxASSERT( msg );
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
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.
|
|
|
|
class IndexBoundsFault : public LogicError
|
|
|
|
{
|
2009-04-27 02:04:31 +00:00
|
|
|
public:
|
|
|
|
const wxString ArrayName;
|
|
|
|
const int ArrayLength;
|
|
|
|
const int BadIndex;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
public:
|
|
|
|
virtual ~IndexBoundsFault() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit IndexBoundsFault( const wxString& objname, int index, int arrsize ) :
|
|
|
|
LogicError( "Index is outside the bounds of an array." ),
|
|
|
|
ArrayName( objname ),
|
|
|
|
ArrayLength( arrsize ),
|
|
|
|
BadIndex( index )
|
|
|
|
{
|
|
|
|
// assertions make debugging easier sometimes. :)
|
2009-05-01 02:15:18 +00:00
|
|
|
wxASSERT( L"Index is outside the bounds of an array" );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
virtual wxString DisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
2009-04-02 11:30:23 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-04-02 11:30:23 +00:00
|
|
|
class ParseError : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~ParseError() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit ParseError( const char* msg="Parse error" ) :
|
2009-04-02 11:30:23 +00:00
|
|
|
RuntimeError( msg ) {}
|
|
|
|
};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
class HardwareDeficiency : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit HardwareDeficiency( const char* msg="Your machine's hardware is incapable of running Pcsx2. Sorry dood." ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
RuntimeError( msg ) {}
|
2009-03-04 13:00:32 +00:00
|
|
|
virtual ~HardwareDeficiency() throw() {}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// This exception is thrown by the PS2 emulation (R5900, etc) when bad things happen
|
|
|
|
// that force the emulation state to terminate. The GUI should handle them by returning
|
|
|
|
// the user to the GUI.
|
|
|
|
class CpuStateShutdown : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~CpuStateShutdown() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit CpuStateShutdown( const char* msg="Unexpected emulation shutdown" ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
RuntimeError( msg ) {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
explicit CpuStateShutdown( const wxString& msg_eng, const wxString& msg_xlt=wxString() ) :
|
2009-05-01 02:15:18 +00:00
|
|
|
RuntimeError( msg_eng, msg_xlt.IsEmpty() ? L"Unexpected emulation shutdown" : msg_xlt ) { }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
class PluginFailure : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
2009-04-02 11:30:23 +00:00
|
|
|
wxString plugin_name; // name of the plugin
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
virtual ~PluginFailure() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
explicit PluginFailure( const char* plugin, const char* msg="%s plugin encountered a critical error" ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
RuntimeError( msg )
|
2009-04-27 02:04:31 +00:00
|
|
|
, plugin_name( wxString::FromAscii(plugin) ) {}
|
|
|
|
|
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
virtual wxString DisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
class ThreadCreationError : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~ThreadCreationError() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit ThreadCreationError( const char* msg="Thread could not be created." ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
RuntimeError( msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// STREAMING EXCEPTIONS
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// Generic stream error. Contains the name of the stream and a message.
|
2009-04-27 02:04:31 +00:00
|
|
|
// This exception is usually thrown via derived classes, except in the (rare) case of a generic / unknown error.
|
2009-02-09 21:15:56 +00:00
|
|
|
class Stream : public RuntimeError
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
virtual ~Stream() throw() {}
|
|
|
|
|
|
|
|
// copy construct!
|
|
|
|
Stream( const Stream& src ) :
|
2009-04-27 02:04:31 +00:00
|
|
|
RuntimeError( src ),
|
|
|
|
StreamName( src.StreamName ) {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
explicit Stream(
|
2009-04-02 11:30:23 +00:00
|
|
|
const wxString& objname=wxString(),
|
2009-04-27 02:04:31 +00:00
|
|
|
const char* msg="General file operation error" // general error while accessing or operating on a file or stream
|
|
|
|
) :
|
|
|
|
RuntimeError( msg ),
|
|
|
|
StreamName( objname ) {}
|
|
|
|
|
|
|
|
explicit Stream( const wxString& objname, const wxString& msg_eng, const wxString& msg_xlt=_("General file operation error") ) :
|
|
|
|
RuntimeError( msg_eng, msg_xlt ),
|
|
|
|
StreamName( objname ) {}
|
|
|
|
|
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
virtual wxString DisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
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.
|
|
|
|
class BadStream : public Stream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~BadStream() throw() {}
|
|
|
|
explicit BadStream(
|
2009-04-02 11:30:23 +00:00
|
|
|
const wxString& objname=wxString(),
|
2009-04-27 02:04:31 +00:00
|
|
|
const char* msg="File data is corrupted or incomplete, or the stream connection closed unexpectedly"
|
|
|
|
) :
|
|
|
|
Stream( objname, msg ) {}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// A generic exception for odd-ball stream creation errors.
|
|
|
|
class CreateStream : public Stream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~CreateStream() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
|
|
|
explicit CreateStream(
|
|
|
|
const char* objname,
|
|
|
|
const char* msg="File could not be created or opened" ) :
|
|
|
|
Stream( wxString::FromAscii( objname ), msg ) {}
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
explicit CreateStream(
|
2009-04-02 11:30:23 +00:00
|
|
|
const wxString& objname=wxString(),
|
2009-04-27 02:04:31 +00:00
|
|
|
const char* msg="File could not be created or opened" ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
Stream( objname, msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
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)
|
|
|
|
class FileNotFound : public CreateStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~FileNotFound() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
explicit FileNotFound(
|
2009-04-02 11:30:23 +00:00
|
|
|
const wxString& objname=wxString(),
|
2009-04-27 02:04:31 +00:00
|
|
|
const char* msg="File not found" ) :
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
CreateStream( objname, msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
class AccessDenied : public CreateStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~AccessDenied() throw() {}
|
|
|
|
explicit AccessDenied(
|
2009-04-02 11:30:23 +00:00
|
|
|
const wxString& objname=wxString(),
|
2009-04-27 02:04:31 +00:00
|
|
|
const char* msg="Permission denied to file" ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
CreateStream( objname, msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// Generic End of Stream exception (sometimes an error, and sometimes just used as a
|
|
|
|
// shortcut for manual feof checks).
|
|
|
|
class EndOfStream : public Stream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~EndOfStream() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit EndOfStream( const wxString& objname, const char* msg="End of file" ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
Stream( objname, msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-03-01 21:49:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// SAVESTATE EXCEPTIONS
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
// Exception thrown when a corrupted or truncated savestate is encountered.
|
|
|
|
class BadSavedState : public BadStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~BadSavedState() throw() {}
|
|
|
|
explicit BadSavedState(
|
2009-04-02 11:30:23 +00:00
|
|
|
const wxString& objname=wxString(),
|
2009-04-27 02:04:31 +00:00
|
|
|
const char* msg="Savestate data is corrupted" ) : // or incomplete
|
2009-02-09 21:15:56 +00:00
|
|
|
BadStream( objname, msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// Exception thrown by SaveState class when a critical plugin or gzread
|
|
|
|
class FreezePluginFailure : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
2009-04-02 11:30:23 +00:00
|
|
|
wxString plugin_name; // name of the plugin
|
|
|
|
wxString freeze_action;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
virtual ~FreezePluginFailure() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit FreezePluginFailure( const char* plugin, const char* action,
|
|
|
|
const wxString& msg_xlt=_("Plugin error occurred while loading/saving state") )
|
|
|
|
:
|
|
|
|
RuntimeError( wxString(), msg_xlt ) // LogMessage / DisplayMessage build their own messages
|
|
|
|
, plugin_name( wxString::FromAscii(plugin) )
|
|
|
|
, freeze_action( wxString::FromAscii(action) ){}
|
|
|
|
|
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
virtual wxString DisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// The savestate code throws Recoverable errors when it fails prior to actually modifying
|
|
|
|
// the current emulation state. Recoverable errors are always thrown from the SaveState
|
|
|
|
// object construction (and never from Freeze methods).
|
|
|
|
class StateLoadError_Recoverable : public RuntimeError
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~StateLoadError_Recoverable() throw() {}
|
2009-04-27 02:04:31 +00:00
|
|
|
explicit StateLoadError_Recoverable( const char* msg="Recoverable savestate load error" ) :
|
2009-02-09 21:15:56 +00:00
|
|
|
RuntimeError( msg ) {}
|
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
2009-02-09 21:15:56 +00:00
|
|
|
// A recoverable exception thrown when the savestate being loaded isn't supported.
|
|
|
|
class UnsupportedStateVersion : public StateLoadError_Recoverable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
u32 Version; // version number of the unsupported state.
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~UnsupportedStateVersion() throw() {}
|
|
|
|
explicit UnsupportedStateVersion( int version ) :
|
2009-04-27 02:04:31 +00:00
|
|
|
StateLoadError_Recoverable(),
|
|
|
|
Version( version )
|
2009-02-09 21:15:56 +00:00
|
|
|
{}
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
virtual wxString DisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
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-02-09 21:15:56 +00:00
|
|
|
class StateCrcMismatch : public StateLoadError_Recoverable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
u32 Crc_Savestate;
|
|
|
|
u32 Crc_Cdvd;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~StateCrcMismatch() throw() {}
|
|
|
|
explicit StateCrcMismatch( u32 crc_save, u32 crc_cdvd )
|
2009-04-27 02:04:31 +00:00
|
|
|
: StateLoadError_Recoverable()
|
2009-02-09 21:15:56 +00:00
|
|
|
, Crc_Savestate( crc_save )
|
|
|
|
, Crc_Cdvd( crc_cdvd )
|
|
|
|
{}
|
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
virtual wxString LogMessage() const;
|
|
|
|
virtual wxString DisplayMessage() const;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
}
|