2009-04-27 02:04:31 +00:00
|
|
|
/* Pcsx2 - Pc Ps2 Emulator
|
|
|
|
* Copyright (C) 2002-2009 Pcsx2 Team
|
|
|
|
*
|
|
|
|
* 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.
|
2009-04-28 05:56:22 +00:00
|
|
|
*
|
2009-04-27 02:04:31 +00:00
|
|
|
* 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.
|
2009-04-28 05:56:22 +00:00
|
|
|
*
|
2009-04-27 02:04:31 +00:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
|
|
|
|
|
|
|
wxString GetEnglish( const char* msg )
|
|
|
|
{
|
2009-07-14 06:18:52 +00:00
|
|
|
return wxString::FromAscii(msg);
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString GetTranslation( const char* msg )
|
|
|
|
{
|
|
|
|
return wxGetTranslation( wxString::FromAscii(msg).c_str() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
namespace Exception
|
|
|
|
{
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
BaseException::~BaseException() throw() {}
|
|
|
|
|
|
|
|
BaseException::BaseException( const wxString& msg_eng, const wxString& msg_xlt ) :
|
|
|
|
m_message_eng( msg_eng ),
|
|
|
|
m_message( msg_xlt ),
|
|
|
|
m_stacktrace( wxEmptyString ) // unsupported yet
|
|
|
|
{
|
|
|
|
// Major hack. After a couple of tries, I'm still not managing to get Linux to catch these exceptions, so that the user actually
|
|
|
|
// gets the messages. Since Console is unavailable at this level, I'm using a simple printf, which of course, means it doesn't get
|
2009-04-28 05:56:22 +00:00
|
|
|
// logged. But at least the user sees it.
|
|
|
|
//
|
2009-04-27 02:04:31 +00:00
|
|
|
// I'll rip this out once I get Linux to actually catch these exceptions. Say, in BeginExecution or StartGui, like I would expect.
|
|
|
|
// -- arcum42
|
|
|
|
#ifdef __LINUX__
|
2009-04-28 05:56:22 +00:00
|
|
|
wxLogError( msg_eng.c_str() );
|
2009-04-27 02:04:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
2009-04-28 05:56:22 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// given message is assumed to be a translation key, and will be stored in translated
|
|
|
|
// and untranslated forms.
|
2009-04-28 05:56:22 +00:00
|
|
|
BaseException::BaseException( const char* msg_eng ) :
|
2009-04-27 02:04:31 +00:00
|
|
|
m_message_eng( GetEnglish( msg_eng ) ),
|
|
|
|
m_message( GetTranslation( msg_eng ) ),
|
|
|
|
m_stacktrace( wxEmptyString ) // unsupported yet
|
|
|
|
{
|
2009-04-28 05:56:22 +00:00
|
|
|
wxLogError( m_message_eng.c_str() );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString BaseException::LogMessage() const
|
|
|
|
{
|
2009-05-01 02:15:18 +00:00
|
|
|
return m_message_eng + L"\n\n" + m_stacktrace;
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxString Stream::LogMessage() const
|
|
|
|
{
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
L"Stream exception: %s\n\tObject name: %s",
|
2009-04-28 05:56:22 +00:00
|
|
|
m_message_eng.c_str(), StreamName.c_str()
|
2009-04-27 02:04:31 +00:00
|
|
|
) + m_stacktrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Stream::DisplayMessage() const
|
|
|
|
{
|
2009-05-01 02:15:18 +00:00
|
|
|
return m_message + L"\n" + StreamName.c_str();
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxString PluginFailure::LogMessage() const
|
|
|
|
{
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
L"%s plugin has encountered an error.\n\n",
|
2009-04-27 02:04:31 +00:00
|
|
|
plugin_name.c_str()
|
|
|
|
) + m_stacktrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString PluginFailure::DisplayMessage() const
|
|
|
|
{
|
2009-04-28 05:56:22 +00:00
|
|
|
return wxsFormat( m_message, plugin_name.c_str() );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxString FreezePluginFailure::LogMessage() const
|
|
|
|
{
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
L"%s plugin returned an error while %s the state.\n\n",
|
2009-04-27 02:04:31 +00:00
|
|
|
plugin_name.c_str(),
|
|
|
|
freeze_action.c_str()
|
|
|
|
) + m_stacktrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FreezePluginFailure::DisplayMessage() const
|
|
|
|
{
|
|
|
|
return m_message;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxString UnsupportedStateVersion::LogMessage() const
|
|
|
|
{
|
|
|
|
// Note: no stacktrace needed for this one...
|
2009-05-01 02:15:18 +00:00
|
|
|
return wxsFormat( L"Unknown or unsupported savestate version: 0x%x", Version );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString UnsupportedStateVersion::DisplayMessage() const
|
|
|
|
{
|
|
|
|
// m_message contains a recoverable savestate error which is helpful to the user.
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
m_message + L"\n\n" +
|
|
|
|
wxsFormat( L"Unknown savestate version: 0x%x", Version )
|
2009-04-27 02:04:31 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxString StateCrcMismatch::LogMessage() const
|
|
|
|
{
|
|
|
|
// Note: no stacktrace needed for this one...
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
L"Game/CDVD does not match the savestate CRC.\n"
|
|
|
|
L"\tCdvd CRC: 0x%X\n\tGame CRC: 0x%X\n",
|
2009-04-27 02:04:31 +00:00
|
|
|
Crc_Savestate, Crc_Cdvd
|
|
|
|
);
|
|
|
|
}
|
2009-04-28 05:56:22 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
wxString StateCrcMismatch::DisplayMessage() const
|
|
|
|
{
|
|
|
|
return wxsFormat(
|
2009-05-01 02:15:18 +00:00
|
|
|
m_message + L"\n\n" +
|
|
|
|
wxsFormat(
|
|
|
|
L"Savestate game/crc mismatch. Cdvd CRC: 0x%X Game CRC: 0x%X\n",
|
2009-04-27 02:04:31 +00:00
|
|
|
Crc_Savestate, Crc_Cdvd
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2009-04-28 05:56:22 +00:00
|
|
|
|
2009-04-27 02:04:31 +00:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxString IndexBoundsFault::LogMessage() const
|
|
|
|
{
|
2009-05-01 02:15:18 +00:00
|
|
|
return L"Index out of bounds on SafeArray: " + ArrayName +
|
|
|
|
wxsFormat( L"(index=%d, size=%d)", BadIndex, ArrayLength );
|
2009-04-27 02:04:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString IndexBoundsFault::DisplayMessage() const
|
|
|
|
{
|
|
|
|
return m_message;
|
|
|
|
}
|
|
|
|
}
|