Changeset 327 for trunk/dll/error.c
- Timestamp:
- Jul 25, 2006, 8:24:42 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/error.c
r293 r327 16 16 27 May 05 SHL Rework to use common showMsg 17 17 14 Aug 05 SHL showMsg: suppress write to stdout if not error message 18 13 Jul 06 SHL Add Runtime_Error 19 22 Jul 06 SHL Optimize calling sequences 18 20 19 21 ***********************************************************************/ … … 35 37 #pragma alloc_text(FMINPUT,Win_Error,Dos_Error,saymsg,showMsg) 36 38 37 static APIRET showMsg(ULONG mb_type, HWND hwnd, CHAR *pszTitle, CHAR *pszMsg);39 static APIRET showMsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszMsg); 38 40 39 41 //== Win_Error: report Win...() error === 40 42 41 VOID Win_Error(HWND hwndErr, HWND hwndOwner, P SZ pszFileName, ULONG ulLineNo, CHAR *pszFmt,...)43 VOID Win_Error(HWND hwndErr, HWND hwndOwner, PCSZ pszFileName, ULONG ulLineNo, PCSZ pszFmt,...) 42 44 { 43 45 PERRINFO pErrInfoBlk; /* Pointer to ERRINFO structure filled … … 60 62 va_end(va); 61 63 64 if (strchr(szMsg, ' ') == NULL) 65 strcat(szMsg, " failed"); // Assume simple function name 66 62 67 // Append file name and line number 63 68 sprintf(szMsg + strlen(szMsg), … … 67 72 // Get last PM error for the current thread 68 73 pErrInfoBlk = WinGetErrorInfo(hab); 69 // fixme to report 70 if (pErrInfoBlk != NULL) 71 { 74 if (!pErrInfoBlk) { 75 psz = szMsg + strlen(szMsg); 76 strcpy(psz, " WinGetError failed"); 77 } 78 else { 72 79 if (!hwndOwner) 73 80 hwndOwner = HWND_DESKTOP; … … 86 93 strcpy(psz, "\""); 87 94 WinFreeErrorInfo(pErrInfoBlk); // Free resource segment 88 89 showMsg(MB_ENTER | MB_ICONEXCLAMATION, 90 hwndOwner,91 GetPString(IDS_GENERR2TEXT), // Titlebar message92 szMsg); // Formattedmessage93 } 95 } 96 97 showMsg(MB_ENTER | MB_ICONEXCLAMATION, 98 hwndOwner, 99 GetPString(IDS_GENERR2TEXT), // Titlebar message 100 szMsg); // Formatted message 94 101 95 102 } // Win_Error … … 97 104 //== Dos_Error: report Dos...() error === 98 105 99 INT Dos_Error(ULONG mb_type, ULONG ulRC, HWND hwndOwner, P SZ pszFileName,100 ULONG ulLineNo, CHAR *pszFmt,...)101 { 102 CHAR szMsg[4096]; 103 ULONG Class = 17; // Error class - fixme to not init?104 ULONG action = 9; // Error action105 ULONG Locus = 7; // Error location106 INT Dos_Error(ULONG mb_type, ULONG ulRC, HWND hwndOwner, PCSZ pszFileName, 107 ULONG ulLineNo, PCSZ pszFmt,...) 108 { 109 CHAR szMsg[4096]; 110 ULONG Class; // Error class 111 ULONG action; // Error action 112 ULONG Locus; // Error location 106 113 ULONG ulMsgLen; 107 114 CHAR *pszMsgStart; … … 116 123 vsprintf(szMsg, pszFmt, va); 117 124 va_end(va); 125 126 if (strchr(szMsg, ' ') == NULL) 127 strcat(szMsg, " failed"); // Assume simple function name 118 128 119 129 DosErrClass(ulRC, &Class, &action, &Locus); … … 168 178 } // Dos_Error 169 179 180 //== Runtime_Error: report runtime library error === 181 182 VOID Runtime_Error(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt,...) 183 { 184 CHAR szMsg[4096]; 185 va_list va; 186 PSZ psz; 187 188 // Format caller's message 189 va_start(va, pszFmt); 190 vsprintf(szMsg, pszFmt, va); 191 va_end(va); 192 193 if (strchr(szMsg, ' ') == NULL) 194 strcat(szMsg, " failed"); // Assume simple function name 195 196 sprintf(szMsg + strlen(szMsg), 197 // GetPString(IDS_DOSERR1TEXT), fixme 198 "\nModule: %s\nLinenumber: %u", 199 pszSrcFile, 200 uSrcLineNo); 201 202 showMsg(MB_ICONEXCLAMATION,HWND_DESKTOP,DEBUG_STRING,szMsg); 203 204 } // Runtime_Error 205 170 206 // fixme to be rename to Misc_Error 171 207 172 208 //=== saymsg: report misc error === 173 209 174 APIRET saymsg(ULONG mb_type, HWND hwnd, CHAR *pszTitle, CHAR *pszFmt,...)210 APIRET saymsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszFmt,...) 175 211 { 176 212 CHAR szMsg[4096]; … … 189 225 //=== showMsg: report misc error === 190 226 191 static APIRET showMsg(ULONG mb_type, HWND hwnd, CHAR *pszTitle, CHAR *pszMsg)227 static APIRET showMsg(ULONG mb_type, HWND hwnd, PCSZ pszTitle, PCSZ pszMsg) 192 228 { 193 229 if ((mb_type & (MB_YESNO | MB_YESNOCANCEL)) == 0) … … 201 237 hwnd = HWND_DESKTOP; 202 238 239 DosBeep(250,100); 240 203 241 return WinMessageBox(HWND_DESKTOP, // Parent 204 242 hwnd, // Owner 205 pszMsg,206 pszTitle,243 (PSZ)pszMsg, 244 (PSZ)pszTitle, 207 245 0, // help id 208 246 mb_type | MB_MOVEABLE);
Note:
See TracChangeset
for help on using the changeset viewer.