mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- made CDoomError inherit from std::exception so that the main catch block can also deal with exceptions thrown by the STL.
- Also do not ignore empty exception messages as irrelevant. The only irrelevant exception type is CNoRunExit.
This commit is contained in:
parent
d4e630c127
commit
bced30d1e3
5 changed files with 25 additions and 14 deletions
|
@ -37,10 +37,11 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <exception>
|
||||
|
||||
#define MAX_ERRORTEXT 1024
|
||||
|
||||
class CDoomError
|
||||
class CDoomError : public std::exception
|
||||
{
|
||||
public:
|
||||
CDoomError ()
|
||||
|
@ -69,13 +70,22 @@ public:
|
|||
else
|
||||
return NULL;
|
||||
}
|
||||
char const *what() const override
|
||||
{
|
||||
return m_Message;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
char m_Message[MAX_ERRORTEXT];
|
||||
};
|
||||
|
||||
class CNoRunExit : public CDoomError
|
||||
class CNoRunExit : public std::exception
|
||||
{
|
||||
public:
|
||||
CNoRunExit() : std::exception("NoRunExit")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class CRecoverableError : public CDoomError
|
||||
|
|
|
@ -46,13 +46,13 @@ void OriginalMainExcept(int argc, char** argv)
|
|||
{
|
||||
OriginalMainTry(argc, argv);
|
||||
}
|
||||
catch(const CDoomError& error)
|
||||
catch(const std::exception& error)
|
||||
{
|
||||
const char* const message = error.GetMessage();
|
||||
const char* const message = error.what();
|
||||
|
||||
if (NULL != message)
|
||||
{
|
||||
fprintf(stderr, "%s\n", message);
|
||||
if (strcmp(message, "NoRunExit")) fprintf(stderr, "%s\n", message);
|
||||
Mac_I_FatalError(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ TArray<FString> I_GetSteamPath()
|
|||
{
|
||||
SteamInstallFolders = ParseSteamRegistry(regPath);
|
||||
}
|
||||
catch(class CDoomError &error)
|
||||
catch(class CRecoverableError &error)
|
||||
{
|
||||
// If we can't parse for some reason just pretend we can't find anything.
|
||||
return result;
|
||||
|
@ -201,7 +201,7 @@ TArray<FString> I_GetSteamPath()
|
|||
{
|
||||
SteamInstallFolders = ParseSteamRegistry(regPath);
|
||||
}
|
||||
catch(class CDoomError &error)
|
||||
catch(class CRecoverableError &error)
|
||||
{
|
||||
// If we can't parse for some reason just pretend we can't find anything.
|
||||
return result;
|
||||
|
|
|
@ -258,11 +258,11 @@ int main (int argc, char **argv)
|
|||
C_InitConsole (80*8, 25*8, false);
|
||||
D_DoomMain ();
|
||||
}
|
||||
catch (class CDoomError &error)
|
||||
catch (std::exception &error)
|
||||
{
|
||||
I_ShutdownJoysticks();
|
||||
if (error.GetMessage ())
|
||||
fprintf (stderr, "%s\n", error.GetMessage ());
|
||||
if (error.what () && strcmp(error.what(), "NoRunExit"))
|
||||
fprintf (stderr, "%s\n", error.what ());
|
||||
|
||||
#ifdef __APPLE__
|
||||
Mac_I_FatalError(error.GetMessage());
|
||||
|
|
|
@ -1048,21 +1048,22 @@ void DoMain (HINSTANCE hInstance)
|
|||
}
|
||||
exit(0);
|
||||
}
|
||||
catch (class CDoomError &error)
|
||||
catch (std::exception &error)
|
||||
{
|
||||
I_ShutdownGraphics ();
|
||||
RestoreConView ();
|
||||
S_StopMusic(true);
|
||||
I_FlushBufferedConsoleStuff();
|
||||
if (error.GetMessage ())
|
||||
auto msg = error.what();
|
||||
if (strcmp(msg, "NoRunExit"))
|
||||
{
|
||||
if (!batchrun)
|
||||
{
|
||||
ShowErrorPane(error.GetMessage());
|
||||
ShowErrorPane(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("%s\n", error.GetMessage());
|
||||
Printf("%s\n", msg);
|
||||
}
|
||||
}
|
||||
exit (-1);
|
||||
|
|
Loading…
Reference in a new issue