5 #include "Common/MyException.h"
\r
6 #include "Common/StdOutStream.h"
\r
8 #include "Windows/Error.h"
\r
9 #include "Windows/NtCheck.h"
\r
11 #include "../Common/ArchiveCommandLine.h"
\r
12 #include "../Common/ExitCode.h"
\r
14 #include "ConsoleClose.h"
\r
16 using namespace NWindows;
\r
18 CStdOutStream *g_StdStream = 0;
\r
22 int numArgs, const char *args[]
\r
26 static const char *kExceptionErrorMessage = "\n\nError:\n";
\r
27 static const char *kUserBreak = "\nBreak signaled\n";
\r
28 static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
\r
29 static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
\r
30 static const char *kInternalExceptionMessage = "\n\nInternal Error #";
\r
32 #define NT_CHECK_FAIL_ACTION (*g_StdStream) << "Unsupported Windows version"; return NExitCode::kFatalError;
\r
37 int numArgs, const char *args[]
\r
41 g_StdStream = &g_StdOut;
\r
45 NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
\r
55 catch(const CNewException &)
\r
57 (*g_StdStream) << kMemoryExceptionMessage;
\r
58 return (NExitCode::kMemoryError);
\r
60 catch(const NConsoleClose::CCtrlBreakException &)
\r
62 (*g_StdStream) << endl << kUserBreak;
\r
63 return (NExitCode::kUserBreak);
\r
65 catch(const CArchiveCommandLineException &e)
\r
67 (*g_StdStream) << kExceptionErrorMessage << e << endl;
\r
68 return (NExitCode::kUserError);
\r
70 catch(const CSystemException &systemError)
\r
72 if (systemError.ErrorCode == E_OUTOFMEMORY)
\r
74 (*g_StdStream) << kMemoryExceptionMessage;
\r
75 return (NExitCode::kMemoryError);
\r
77 if (systemError.ErrorCode == E_ABORT)
\r
79 (*g_StdStream) << endl << kUserBreak;
\r
80 return (NExitCode::kUserBreak);
\r
83 NError::MyFormatMessage(systemError.ErrorCode, message);
\r
84 (*g_StdStream) << endl << endl << "System error:" << endl << message << endl;
\r
85 return (NExitCode::kFatalError);
\r
87 catch(NExitCode::EEnum &exitCode)
\r
89 (*g_StdStream) << kInternalExceptionMessage << exitCode << endl;
\r
93 catch(const NExitCode::CMultipleErrors &multipleErrors)
\r
95 (*g_StdStream) << endl << multipleErrors.NumErrors << " errors" << endl;
\r
96 return (NExitCode::kFatalError);
\r
99 catch(const UString &s)
\r
101 (*g_StdStream) << kExceptionErrorMessage << s << endl;
\r
102 return (NExitCode::kFatalError);
\r
104 catch(const AString &s)
\r
106 (*g_StdStream) << kExceptionErrorMessage << s << endl;
\r
107 return (NExitCode::kFatalError);
\r
109 catch(const char *s)
\r
111 (*g_StdStream) << kExceptionErrorMessage << s << endl;
\r
112 return (NExitCode::kFatalError);
\r
116 (*g_StdStream) << kInternalExceptionMessage << t << endl;
\r
117 return (NExitCode::kFatalError);
\r
121 (*g_StdStream) << kUnknownExceptionMessage;
\r
122 return (NExitCode::kFatalError);
\r