ErrorHandler.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Installer *
  23. * *
  24. * $Archive:: /Commando/Code/Installer/ErrorHandler.cpp $*
  25. * *
  26. * $Author:: Ian_l $*
  27. * *
  28. * $Modtime:: 11/25/01 6:56p $*
  29. * *
  30. * $Revision:: 7 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. // Includes.
  36. #include "ErrorHandler.h"
  37. #include "CodeControl.h"
  38. #include "Resource.h"
  39. #include "Translator.h"
  40. #include "Win.h"
  41. // Defines.
  42. #if VERBOSE_ERROR_MESSAGES
  43. #define SYSTEM_ERROR_FORMAT_STRING L"%s\nFile: %s\nLine: %d\n"
  44. #define APPLICATION_ERROR_FORMAT_STRING L"%s\n\nFile: %s\nLine: %d\n"
  45. #define CAB_ERROR_FORMAT_STRING L"%s %d\n\nFile: %s\nLine: %d\n"
  46. #else
  47. #define SYSTEM_ERROR_FORMAT_STRING L"%s"
  48. #define APPLICATION_ERROR_FORMAT_STRING L"%s"
  49. #define CAB_ERROR_FORMAT_STRING L"%s %d"
  50. #endif
  51. /***********************************************************************************************
  52. * Handle_Fatal_System_Error -- *
  53. * *
  54. * INPUT: *
  55. * *
  56. * OUTPUT: *
  57. * *
  58. * WARNINGS: *
  59. * *
  60. * HISTORY: *
  61. * 08/22/01 IML : Created. *
  62. *=============================================================================================*/
  63. void Handle_Fatal_System_Error (int errorcode, const char *filename, int sourceline)
  64. {
  65. WideStringClass errormessage, messagebody;
  66. LPVOID messagebuffer;
  67. FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
  68. NULL,
  69. errorcode,
  70. MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
  71. (LPTSTR) &messagebuffer,
  72. 0,
  73. NULL);
  74. messagebody = (TCHAR*) messagebuffer;
  75. LocalFree (messagebuffer);
  76. #if VERBOSE_ERROR_MESSAGES
  77. errormessage.Format (SYSTEM_ERROR_FORMAT_STRING, messagebody, WideStringClass (filename), sourceline);
  78. #else
  79. errormessage.Format (SYSTEM_ERROR_FORMAT_STRING, messagebody);
  80. #endif
  81. throw (errormessage);
  82. }
  83. /***********************************************************************************************
  84. * Handle_Fatal_Application_Error -- *
  85. * *
  86. * INPUT: *
  87. * *
  88. * OUTPUT: *
  89. * *
  90. * WARNINGS: *
  91. * *
  92. * HISTORY: *
  93. * 08/22/01 IML : Created. *
  94. *=============================================================================================*/
  95. void Handle_Fatal_Application_Error (int errorcode, const char *filename, int sourceline)
  96. {
  97. WideStringClass errormessage;
  98. #if VERBOSE_ERROR_MESSAGES
  99. errormessage.Format (APPLICATION_ERROR_FORMAT_STRING, TxWideStringClass (errorcode), WideStringClass (filename), sourceline);
  100. #else
  101. errormessage.Format (APPLICATION_ERROR_FORMAT_STRING, TxWideStringClass (errorcode));
  102. #endif
  103. throw (errormessage);
  104. }
  105. /***********************************************************************************************
  106. * Handle_Fatal_Cab_Error -- *
  107. * *
  108. * INPUT: *
  109. * *
  110. * OUTPUT: *
  111. * *
  112. * WARNINGS: *
  113. * *
  114. * HISTORY: *
  115. * 08/22/01 IML : Created. *
  116. *=============================================================================================*/
  117. void Handle_Fatal_Cab_Error (int errorcode, const char *filename, int sourceline)
  118. {
  119. WideStringClass errormessage;
  120. #if VERBOSE_ERROR_MESSAGES
  121. errormessage.Format (CAB_ERROR_FORMAT_STRING, TxWideStringClass (IDS_CAB_ERROR), errorcode, WideStringClass (filename), sourceline);
  122. #else
  123. errormessage.Format (CAB_ERROR_FORMAT_STRING, TxWideStringClass (IDS_CAB_ERROR), errorcode);
  124. #endif
  125. throw (errormessage);
  126. }