00001 // $Id: errors.h 1140 2006-05-19 19:49:43Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 // inform.h : header file 00099 // 00100 00101 00102 /* 00103 */ 00104 00105 00106 #ifndef INC_ERRORS 00107 #define INC_ERRORS 00108 00109 00110 //#include "errordlg.h" 00111 00112 // The various error types below are used to pass to InformGeneral by the inline functions InformError, 00113 // InformWarning etc. They are also stored inside the class CInformErrorDialogue 00114 #define ERRORTYPE_NORMAL 0 00115 #define ERRORTYPE_QUESTION 1 00116 #define ERRORTYPE_WARNING 2 00117 #define ERRORTYPE_ERROR 3 00118 #define ERRORTYPE_SERIOUS 4 00119 #define ERRORTYPE_ENSURE 5 00120 00121 #if !defined(EXCLUDE_FROM_XARLIB) 00122 /******************************************************************************************** 00123 00124 > class ErrorInfo 00125 00126 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00127 Created: 04/07/94 00128 Purpose: Describe the error/warning/question that is to be displayed. 00129 Fields are: 00130 MonoOn 00131 ErrorMsg - Resource ID of the error message. 00132 Title - resource ID of the dialogue title string (optional) 00133 Button - array of up to 4 button string resource IDs. 00134 OK - the button which is the 'OK' or default button, i.e. the one which 00135 should be activated by Enter (this in the range 1-4). 00136 Cancel - the button which is the 'Cancel' button, i.e. the one which should 00137 be activated by Esc (this in the range 1-4). 00138 Help - the index of the button which is the 'Help' button (this in the 00139 range 1-4). 00140 MonoOff 00141 SeeAlso: InformGeneral 00142 00143 ********************************************************************************************/ 00144 00145 class ErrorInfo 00146 { 00147 public: 00148 ErrorInfo(); 00149 00150 UINT32 ErrorMsg; 00151 UINT32 Title; 00152 UINT32 Button[4]; 00153 UINT32 OK; 00154 UINT32 Cancel; 00155 UINT32 Help; 00156 }; 00157 00158 // The function used throughout the program should be moved to its own .h file really 00159 INT32 CCAPI InformGeneral(UINT32 Error, 00160 UINT32 modID, UINT32 ErrorMsg, 00161 UINT32 Butt1, UINT32 Butt2, UINT32 Butt3, UINT32 Butt4, 00162 UINT32 OK, UINT32 Cancel); 00163 00164 INT32 CCAPI InformGeneral(UINT32 Error, ErrorInfo *pInfo, UINT32 ModID = 0); 00165 00166 00167 void CCAPI InformLastError(UINT32 Error = ERRORTYPE_ERROR); 00168 00169 00170 // These functions are no longer inline as this just caused huge dependancy problems 00171 // Errors first: 00172 INT32 InformError(UINT32 ErrorMsg = 0, 00173 UINT32 Butt1 = 0, 00174 UINT32 Butt2 = 0, 00175 UINT32 Butt3 = 0, 00176 UINT32 Butt4 = 0, 00177 UINT32 OK = 1, 00178 UINT32 Cancel = 2); 00179 00180 INT32 ToolInformError(UINT32 ToolID, 00181 UINT32 ErrorMsg = 0, 00182 UINT32 Butt1 = 0, 00183 UINT32 Butt2 = 0, 00184 UINT32 Butt3 = 0, 00185 UINT32 Butt4 = 0, 00186 UINT32 OK = 1, 00187 UINT32 Cancel = 2); 00188 00189 00190 INT32 ModuleInformError(UINT32 ModID, 00191 UINT32 ErrorMsg = 0, 00192 UINT32 Butt1 = 0, 00193 UINT32 Butt2 = 0, 00194 UINT32 Butt3 = 0, 00195 UINT32 Butt4 = 0, 00196 UINT32 OK = 1, 00197 UINT32 Cancel = 2); 00198 00199 INT32 InformError(ErrorInfo *pInfo); 00200 INT32 ToolInformError(UINT32 ToolID, ErrorInfo *pInfo); 00201 INT32 ModuleInformError(UINT32 ModID, ErrorInfo *pInfo); 00202 00203 // now serious errors 00204 INT32 InformSeriousError(UINT32 ErrorMsg = 0, 00205 UINT32 Butt1 = 0, 00206 UINT32 Butt2 = 0, 00207 UINT32 Butt3 = 0, 00208 UINT32 Butt4 = 0, 00209 UINT32 OK = 1, 00210 UINT32 Cancel = 2); 00211 00212 INT32 ToolInformSeriousError(UINT32 ToolID, 00213 UINT32 ErrorMsg = 0, 00214 UINT32 Butt1 = 0, 00215 UINT32 Butt2 = 0, 00216 UINT32 Butt3 = 0, 00217 UINT32 Butt4 = 0, 00218 UINT32 OK = 1, 00219 UINT32 Cancel = 2); 00220 00221 INT32 ModuleInformSeriousError(UINT32 ModID, 00222 UINT32 ErrorMsg = 0, 00223 UINT32 Butt1 = 0, 00224 UINT32 Butt2 = 0, 00225 UINT32 Butt3 = 0, 00226 UINT32 Butt4 = 0, 00227 UINT32 OK = 1, 00228 UINT32 Cancel = 2); 00229 00230 INT32 InformSeriousError(ErrorInfo *pInfo); 00231 INT32 ToolInformSeriousError(UINT32 ToolID, ErrorInfo *pInfo); 00232 INT32 ModuleInformSeriousError(UINT32 ModID, ErrorInfo *pInfo); 00233 00234 // now warnings: 00235 INT32 InformWarning(UINT32 ErrorMsg = 0, 00236 UINT32 Butt1 = 0, 00237 UINT32 Butt2 = 0, 00238 UINT32 Butt3 = 0, 00239 UINT32 Butt4 = 0, 00240 UINT32 OK = 1, 00241 UINT32 Cancel = 2); 00242 00243 00244 INT32 ToolInformWarning(UINT32 ToolID, 00245 UINT32 ErrorMsg = 0, 00246 UINT32 Butt1 = 0, 00247 UINT32 Butt2 = 0, 00248 UINT32 Butt3 = 0, 00249 UINT32 Butt4 = 0, 00250 UINT32 OK = 1, 00251 UINT32 Cancel = 2); 00252 00253 00254 INT32 ModuleInformWarning(UINT32 ModID, 00255 UINT32 ErrorMsg = 0, 00256 UINT32 Butt1 = 0, 00257 UINT32 Butt2 = 0, 00258 UINT32 Butt3 = 0, 00259 UINT32 Butt4 = 0, 00260 UINT32 OK = 1, 00261 UINT32 Cancel = 2); 00262 00263 INT32 InformWarning(ErrorInfo *pInfo); 00264 INT32 ToolInformWarning(UINT32 ToolID, ErrorInfo *pInfo); 00265 INT32 ModuleInformWarning(UINT32 ModID, ErrorInfo *pInfo); 00266 00267 // questions: 00268 UINT32 AskQuestion(UINT32 ErrorMsg = 0, 00269 UINT32 Butt1 = 0, 00270 UINT32 Butt2 = 0, 00271 UINT32 Butt3 = 0, 00272 UINT32 Butt4 = 0, 00273 UINT32 OK = 1, 00274 UINT32 Cancel = 2); 00275 00276 00277 UINT32 ToolAskQuestion(UINT32 ToolID, 00278 UINT32 ErrorMsg = 0, 00279 UINT32 Butt1 = 0, 00280 UINT32 Butt2 = 0, 00281 UINT32 Butt3 = 0, 00282 UINT32 Butt4 = 0, 00283 UINT32 OK = 1, 00284 UINT32 Cancel = 2); 00285 00286 00287 INT32 ModuleAskQuestion(UINT32 ModID, 00288 UINT32 ErrorMsg = 0, 00289 UINT32 Butt1 = 0, 00290 UINT32 Butt2 = 0, 00291 UINT32 Butt3 = 0, 00292 UINT32 Butt4 = 0, 00293 UINT32 OK = 1, 00294 UINT32 Cancel = 2); 00295 00296 INT32 AskQuestion(ErrorInfo *pInfo); 00297 INT32 ToolAskQuestion(UINT32 ToolID, ErrorInfo *pInfo); 00298 INT32 ModuleAskQuestion(UINT32 ModID, ErrorInfo *pInfo); 00299 00300 00301 // now just messages: 00302 INT32 InformMessage(UINT32 ErrorMsg = 0, 00303 UINT32 Butt1 = 0, 00304 UINT32 Butt2 = 0, 00305 UINT32 Butt3 = 0, 00306 UINT32 Butt4 = 0, 00307 UINT32 OK = 1, 00308 UINT32 Cancel = 2); 00309 00310 00311 INT32 ToolInformMessage(UINT32 ToolID, 00312 UINT32 ErrorMsg = 0, 00313 UINT32 Butt1 = 0, 00314 UINT32 Butt2 = 0, 00315 UINT32 Butt3 = 0, 00316 UINT32 Butt4 = 0, 00317 UINT32 OK = 1, 00318 UINT32 Cancel = 2); 00319 00320 INT32 ModuleInformMessage(UINT32 ModID, 00321 UINT32 ErrorMsg = 0, 00322 UINT32 Butt1 = 0, 00323 UINT32 Butt2 = 0, 00324 UINT32 Butt3 = 0, 00325 UINT32 Butt4 = 0, 00326 UINT32 OK = 1, 00327 UINT32 Cancel = 2); 00328 00329 INT32 InformMessage(ErrorInfo *pInfo); 00330 INT32 ToolInformMessage(UINT32 ToolID, ErrorInfo *pInfo); 00331 INT32 ModuleInformMessage(UINT32 ModID, ErrorInfo *pInfo); 00332 #endif 00333 00334 00335 /*********************************************************************************************** 00336 00337 > macro ERROR(UINT32 ErrID, retvalue) 00338 00339 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00340 Created: 9/7/93 00341 Purpose: This macro should be used to return from a function when an error condition 00342 has been detected. The rule in Camelot is that every function which might 00343 fail should return a BOOL indicating success or failure. Thus, retvalue will 00344 usually be FALSE. However, functions which return pointers can indicate error 00345 conditions by returning NULL, so the retvalue parameter is there to give extra 00346 functionality. Obviously, TRUE or FALSE (or NULL) tells us very little about why 00347 a function failed, so we have a class containing static variables which must be 00348 set each time a function fails. A calling routine can look at the error value to 00349 see what the error was, or use the string to present the error in an error box. 00350 The macro has two incarnations - within module code in a separate DLL it passes a 00351 Module ID, which allows the string finding functions to look in another resource, 00352 while within kernel code, it just passes the error ID. 00353 It looks at the symbol MODULE_ID to see if it is being defined within a module, 00354 and defines the appropriate behaviour. MODULE_ID should be defined as a unique 00355 module identifier in all code running in a module. It should not be defined in any 00356 other code. 00357 Warning: Windows.h defines ERROR as 0 for region functions. Use of this together 00358 with errors.h should be treated carefully. 00359 SeeAlso: TOOLERROR; ERRORIF; Error 00360 00361 ***********************************************************************************************/ 00362 00363 /********************************************************************************************* 00364 00365 > macro TOOLERROR(UINT32 ErrID, retvalue, toolID) 00366 00367 Author: Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com> 00368 Created: 20/8/93 00369 Purpose: Like ERROR, except specially for Tools to use. 00370 If you are a Tool you can use the TOOLERROR macro which takes a third parameter, 00371 that of your tool ID. MODULE_ID does not need to be defined for this to work. 00372 SeeAlso: ERROR; TOOLERRORIF; Error 00373 00374 *********************************************************************************************/ 00375 00376 #ifdef ERROR 00377 #undef ERROR 00378 #endif 00379 00380 #ifndef MODULE_ID 00381 00382 #define ERROR(errID, retparam) \ 00383 Error::SetError( errID, 0 ); \ 00384 return retparam; 00385 00386 #else 00387 00388 #define ERROR(errID, retparam) \ 00389 Error::SetError(errID, MODULE_ID); \ 00390 return retparam; 00391 00392 #endif 00393 00394 #define TOOLERROR(errID, retparam, toolid) \ 00395 Error::SetErrorTool(errID, toolid); \ 00396 return retparam; 00397 00398 00399 00400 /*********************************************************************************************** 00401 00402 > macro ERRORIF(condition, UINT32 ErrID, retvalue) 00403 00404 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00405 Created: 9/7/93 00406 Inputs: condition is a boolean expression, TRUE if error should be returned. 00407 ErrID is an error number/resource (all the same) 00408 retvalue is the value that will be returned from the function. 00409 Purpose: This is a general purpose macro which is a bit like ENSURE, except that it really 00410 does return an error to the calling code. 00411 This macro should be used at the beginning of a member function, to test for 00412 the known conditions that the function works to. All functions should know what 00413 conditions they expect before they start, and they should fail if those conditions 00414 are not met. The condition should be a boolean expression which should evaluate 00415 to TRUE if an error condition has manifested itself, at which time the ERROR macro 00416 is executed, making the function return whatever you put in retvalue. 00417 Usually, retvalue will be FALSE, since most functions that fail are expected to 00418 return a BOOL. However, some functions can usefully return other error indicators. 00419 For example, a function which returns a pointer can return NULL to indicate an error. 00420 Thus, you can use the macro as: 00421 00422 ERRORIF(num != 42, _R(ID_BADPARAM), FALSE); 00423 or 00424 ERRORIF(!ptr, _R(ID_BADPOINTER), NULL); 00425 00426 SeeAlso: ERROR; Error 00427 00428 ***********************************************************************************************/ 00429 00430 /********************************************************************************************* 00431 00432 > macro TOOLERRORIF(condition, UINT32 ErrID, retvalue, toolID) 00433 00434 Author: Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com> 00435 Created: 20/8/93 00436 Purpose: Like ERRORIF, except specially for Tools to use. 00437 If you are a Tool you can use the TOOLERROR macro which takes a third parameter, 00438 that of your tool ID. MODULE_ID does not need to be defined for this to work. 00439 SeeAlso: ERRORIF; TOOLERROR; Error 00440 00441 *********************************************************************************************/ 00442 00443 00444 #define ERRORIF(cond,returnID, retvalue)\ 00445 if (cond) \ 00446 { \ 00447 ERROR( returnID, retvalue ); \ 00448 } 00449 00450 00451 #define TOOLERRORIF(cond,returnID,retvalue,toolid) \ 00452 if (cond) \ 00453 { \ 00454 TOOLERROR((UINT32)returnID, retvalue,toolid); \ 00455 } 00456 00457 00458 // INLINE_MARKERROR non-zero if MarkError function is inline 00459 // this is done in retail builds, except in DLL code 00460 #if defined(_DEBUG) || defined(_AFXDLL) 00461 #define INLINE_MARKERROR 0 00462 #else 00463 #define INLINE_MARKERROR 1 00464 #endif 00465 // MARKERROR_BODY is used to expand the actual function as required 00466 #define MARKERROR_BODY(Line,File) { LastErrorLine = Line; LastErrorFile = File; } 00467 00468 #define MAXERRORFORMATLENGTH 256 00469 00470 /*********************************************************************************************** 00471 00472 > class Error 00473 00474 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00475 Created: 9/7/93 00476 Purpose: The Error class consists only of static variables, one for the ID of the error, 00477 another for the string, and another for the ID of the module that generated the 00478 error (0 if the error happened in the kernel). The string is a simple TCHAR array 00479 to avoid the need for dynamic memory allocation during error handling. These 00480 variables must be set whenever an error condition manifests itself. The class 00481 provides static functions to do this, which are called by the ERRORIF and 00482 NERROR macros 00483 SeeAlso: ERRORIF; ERROR 00484 00485 ***********************************************************************************************/ 00486 00487 class CCAPI Error 00488 { 00489 private: 00490 static UINT32 ErrorID; 00491 00492 // Chris introduced RalphErrorID during ralph error handling 00493 // ralph needs this so that he can map the ID to a HRESULT before passing it 00494 // back to a harness - the current ErrorId is cleared in SetSeriousError maybe by design 00495 // To be safe we'll keep our own copy. 00496 00497 static UINT32 RalphErrorID; 00498 static UINT32 ModuleID; 00499 static TCHAR ErrorString[256]; 00500 static UINT32 RenderThread; // This is incremented each time we start something that looks 00501 // like a render, and decremented as we thread out. So if an error 00502 // occurs, we know we have to be very careful 00503 00504 static UINT32 LastErrorLine; // line number of last error (or 0) 00505 static const char *LastErrorFile; // ptr to filename of last error 00506 00507 static wxString UserName; 00508 00509 static void TraceWrite(const TCHAR * buf, va_list args); 00510 static void FixFormat (const TCHAR * fmt, TCHAR * fmt2); 00511 #if 0 != wxUSE_UNICODE 00512 // In UNICODE builds ONLY we allow an additional char * version of which copes with old code 00513 // that does ERROR3PF("foo", ...), not ERROR3PF(_T("foo", ....). We don't include these 00514 // in the non-Unicode version as they clash with the TCHAR stuff 00515 static void FixFormat (const char * fmt, TCHAR * fmt2); 00516 #endif 00517 00518 public: 00519 Error() 00520 { 00521 ErrorString[0] = 0; 00522 RalphErrorID =ErrorID = ModuleID = 0; 00523 } 00524 00525 static BOOL IsUserName(const char *wanted); 00526 00527 static void SetUserName(wxString User) { UserName = User; } 00528 00529 // convert ID's to HRESULT for ralph harness's 00530 static HRESULT ErrIDToHRESULT(UINT32 ErrID); 00531 00532 #if !defined(EXCLUDE_FROM_XARLIB) 00533 static HRESULT GetRalphError(); 00534 #endif 00535 00536 ~Error(); 00537 static void SetError(UINT32 number, const TCHAR* errstring, UINT32 module); 00538 static void SetError(UINT32 number, UINT32 module = 0); 00539 static void SetErrorTool(UINT32 number, UINT32 toolid); 00540 static void SetErrorSerious( const TCHAR* ); 00541 00542 static void ClearError(); 00543 00544 inline static TCHAR* GetErrorString(); 00545 00546 inline static UINT32 GetErrorNumber(); 00547 inline static UINT32 GetRalphErrorNumber(); 00548 00549 inline static UINT32 GetErrorModule(); 00550 00551 inline static void RenderThreadIn() { RenderThread++; } 00552 inline static void RenderThreadOut() { RenderThread--; } 00553 inline static void RenderThreadReset() { RenderThread = 0; } 00554 inline static BOOL IsInRenderThread() { return ( RenderThread != 0 ); } 00555 00556 static void DirectStatus( BOOL = FALSE ); 00557 00558 static void MarkError( UINT32 LineNumber, const char *Filename ) 00559 #if INLINE_MARKERROR 00560 MARKERROR_BODY( LineNumber, Filename ) 00561 #else 00562 ; 00563 #endif 00564 00565 00566 static void CDECL XSetErrorC(); 00567 static void CDECL XSetError(const TCHAR *fmt, ...); 00568 #if 0 != wxUSE_UNICODE 00569 // In UNICODE builds ONLY we allow an additional char * version of which copes with old code 00570 // that does ERROR3PF("foo", ...), not ERROR3PF(_T("foo", ....). We don't include these 00571 // in the non-Unicode version as they clash with the TCHAR stuff 00572 static void CDECL XSetError(const char *fmt, ...); 00573 #endif 00574 static void CDECL XSetError(UINT32, ...); 00575 static void CDECL ReleaseTrace(LPCTSTR, ...); 00576 #ifdef _DEBUG 00577 static void CDECL XComplain(const TCHAR *fmt, ...); 00578 #if 0 != wxUSE_UNICODE 00579 // In UNICODE builds ONLY we allow an additional char * version of which copes with old code 00580 // that does ERROR3PF("foo", ...), not ERROR3PF(_T("foo", ....). We don't include these 00581 // in the non-Unicode version as they clash with the TCHAR stuff 00582 static void CDECL XComplain(const char *fmt, ...); 00583 #endif 00584 static void CDECL TraceUser(const char *, LPCTSTR, ...); 00585 static void CDECL TraceAll( LPCTSTR, ...); 00586 static void CDECL TraceTime (TCHAR * t); 00587 #else 00588 static void CDECL TraceUser(const char *, LPCTSTR, ...) { } 00589 static void CDECL TraceAll( LPCTSTR, ...) { } 00590 static void CDECL TraceTime (TCHAR *) { } 00591 #endif 00592 00593 // Stack walking stuff 00594 public: 00595 static void DumpStack(UINT32 frames=0); 00596 00597 // FreeBSD does not provide backtrace() 00598 #if !defined(__WXMAC__) && !defined(__FreeBSD__) 00599 class StackWalker : public wxStackWalker 00600 { 00601 public: 00602 virtual void OnStackFrame(const wxStackFrame & frame); 00603 }; 00604 #endif 00605 00606 static UINT32 ErrorBoxRecurse; 00607 00608 }; 00609 00610 /*********************************************************************************************** 00611 00612 > void Error::RenderThreadIn() 00613 void Error::RenderThreadOut() 00614 void Error::RenderThreadReset() 00615 00616 Author: Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com> 00617 Created: 25/2/94 00618 Inputs: - 00619 Outputs: - 00620 Returns: - 00621 Purpose: Notes the threading in or out of rendering (i.e. whether the program is somewhere 00622 within a render loop). Each RenderThreadIn should be paired with a RenderThreadOut 00623 and placed around rendering code. They may be nested. RenderThreadReset notes an 00624 abnormal termination of the thread (for instance an exception). Whilst in render 00625 threads, errors are handled slightly differently. Hence the need to know. 00626 Errors: - 00627 SeeAlso: Error::IsInRenderThread 00628 00629 ***********************************************************************************************/ 00630 00631 /*********************************************************************************************** 00632 00633 > BOOL Error::IsInRenderThread() 00634 00635 Author: Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com> 00636 Created: 25/2/94 00637 Inputs: - 00638 Outputs: - 00639 Returns: TRUE if in a render thread, else FALSE 00640 Purpose: Tells the caller whether or not Camelot is in a render thread. If so, if an error 00641 occurs, it is likely to be (a) nasty, and (b) repeated many times, so more forceful 00642 action is taken to get rid of it. 00643 Errors: - 00644 SeeAlso: Error::RenderThreadIn, Error::RenderThreadOut, Error::RenderThreadReset 00645 00646 ***********************************************************************************************/ 00647 00648 /*********************************************************************************************** 00649 00650 > TCHAR* Error::GetErrorString() 00651 00652 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00653 Created: 9/7/93 00654 Inputs: - 00655 Outputs: - 00656 Returns: pointer to TCHAR array containing last error 00657 Purpose: Gets the string associated with the last error from the static error variables. 00658 Usually used by an operation to report why the operation failed. 00659 Errors: - 00660 SeeAlso: Error::GetErrorNumber;Error::GetErrorModule; Error::SetError 00661 00662 ***********************************************************************************************/ 00663 00664 TCHAR* Error::GetErrorString() 00665 { 00666 return ErrorString; 00667 } 00668 00669 /*********************************************************************************************** 00670 00671 > UINT32 Error::GetRalphErrorNumber() 00672 00673 Author: Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> 00674 Created: 9/7/96 00675 Inputs: - 00676 Outputs: - 00677 Returns: Error number of last error that occurred 00678 Purpose: As GetERrorNumber EXCEPT this returns the ralph copy of ErrorID that is not 00679 cleared in SetSeriousError() 00680 Errors: - 00681 SeeAlso: Error::GetErrorString; Error::GetErrorModule; Error::SetError 00682 00683 ***********************************************************************************************/ 00684 00685 UINT32 Error::GetRalphErrorNumber() 00686 { 00687 // if ErrorId is zero (it may have been cleared in SetSeriousError ) 00688 // return RalphErrorID 00689 if( ErrorID == 0) 00690 return RalphErrorID; 00691 else 00692 return ErrorID; 00693 } 00694 00695 /*********************************************************************************************** 00696 00697 > UINT32 Error::GetErrorNumber() 00698 00699 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00700 Created: 9/7/93 00701 Inputs: - 00702 Outputs: - 00703 Returns: Error number of last error that occurred 00704 Purpose: If a function returns failure, this function will read the error number. 00705 This is usually associated with a resource of some kind - in Win16 it will 00706 be the 16bit resource ID, in RISC OS it will be a 32bit resource ID, etc. 00707 There is always an associated string (reached by GetErrorString) so routines 00708 wanting to report the error do not need to do any nasty resource loading. 00709 Errors: - 00710 SeeAlso: Error::GetErrorString; Error::GetErrorModule; Error::SetError 00711 00712 ***********************************************************************************************/ 00713 00714 UINT32 Error::GetErrorNumber() 00715 { 00716 return ErrorID; 00717 } 00718 00719 00720 00721 /*********************************************************************************************** 00722 00723 > UINT32 Error::GetErrorModule() 00724 00725 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00726 Created: 9/7/93 00727 Inputs: - 00728 Outputs: - 00729 Returns: Unique UINT32 identifying the module that generated the last error 00730 (zero if the last error was in the kernel). 00731 Purpose: Mainly for debugging - the UINT32 is a unique identifier which will tell a 00732 programmer which module generated the last error. This will never be visible 00733 to a user. 00734 Errors: - 00735 SeeAlso: Error::GetErrorNumber; Error::GetErrorString; Error::SetError 00736 00737 ***********************************************************************************************/ 00738 00739 UINT32 Error::GetErrorModule() 00740 { 00741 return ModuleID; 00742 } 00743 00744 // all-new error macros 00745 00746 #define MARKWHERE Error::MarkError( __LINE__, __FILE__ ) 00747 #ifdef _DEBUG 00748 #define MARKWHEREDB MARKWHERE 00749 #else 00750 #define MARKWHEREDB 00751 #endif 00752 00753 #define ERROR1RAW( errorID ) do { MARKWHEREDB; Error::XSetError( errorID ); } while(0) 00754 #define ERROR1( retvalue, errorID ) do { MARKWHEREDB; Error::XSetError( errorID ); return (retvalue); } while(0) 00755 #define ERROR1IF( condition, retvalue, errorID ) do { if (condition) ERROR1( retvalue, errorID ); } while(0) 00756 #define ERROR1_MSG( retvalue, args ) do { MARKWHEREDB; Error::XSetError args ; return (retvalue); } while(0) 00757 #define ERROR1IF_MSG( condition, retvalue, args ) do { if (condition) ERROR1_MSG( retvalue, args ); } while(0) 00758 00759 #ifdef _DEBUG 00760 #define ERROR2RAW( literal ) do { MARKWHERE; Error::XSetError( literal ); } while(0) 00761 #define ERROR2( retvalue, literal ) do { MARKWHERE; Error::XSetError( literal ); return (retvalue); } while(0) 00762 #define ERROR2IF( condition, retvalue, literal ) do { if (condition) ERROR2( retvalue, literal ); } while (0) 00763 #define ERROR2_PF( retvalue, args ) do { MARKWHERE; Error::XSetError args ; return (retvalue); } while(0) 00764 #define ERROR2IF_PF( condition, retvalue, args ) do { if (condition) ERROR2_PF( retvalue, args ); } while (0) 00765 00766 #define ERROR3(literal) do { MARKWHERE; Error::XComplain( literal ); } while(0) 00767 #define ERROR3IF(condition, literal) do { if (condition) ERROR3(literal); } while(0) 00768 #define ERROR3_PF(args) do { MARKWHERE; Error::XComplain args; } while(0) 00769 #define ERROR3IF_PF(condition, args) do { if (condition) ERROR3_PF(args); } while(0) 00770 #define TRACEUSER Error::TraceUser 00771 #define TRACEALL TRACE 00772 #define RELTRACE Error::ReleaseTrace 00773 #define TRACE Error::TraceAll 00774 #define TRACET Error::TraceTime 00775 #define TRACE0 Error::TraceAll 00776 #define ASSERT wxASSERT 00777 00778 #else // _DEBUG 00779 00780 #define ERROR2RAW( literal ) do { MARKWHERE; Error::XSetErrorC(); } while(0) 00781 #define ERROR2( retvalue, literal ) do { MARKWHERE; Error::XSetErrorC(); return (retvalue); } while(0) 00782 #define ERROR2IF( condition, retvalue, literal ) do { if (condition) ERROR2( retvalue, literal ); } while(0) 00783 #define ERROR2_PF( retvalue, args ) do { MARKWHERE; Error::XSetError args ; return (retvalue); } while(0) 00784 #define ERROR2IF_PF( condition, retvalue, args ) do { if (condition) ERROR2_PF( retvalue, args ); } while(0) 00785 00786 #define ERROR3(literal) do { } while (0) 00787 #define ERROR3IF(condition, literal) do { } while (0) 00788 #define ERROR3_PF(args) do { } while (0) 00789 #define ERROR3IF_PF(condition, args) do { } while (0) 00790 #define TRACEUSER 1 ? (void)0 : Error::TraceUser 00791 #define TRACEALL TRACE 00792 #define RELTRACE Error::ReleaseTrace 00793 00794 #define TRACE 1 ? (void)0 : Error::TraceAll 00795 #define TRACE0 1 ? (void)0 : Error::TraceAll 00796 #define TRACET 1 ? (void)0 : Error::TraceAll 00797 #define ASSERT(condition) do { } while (0) 00798 00799 #endif // _DEBUG 00800 00801 00802 00803 #if defined(_DEBUG) && defined(SHOWPORTNOTE) && defined(EXCLUDE_FROM_XARALX) 00804 #ifdef __GNUG__ 00805 #define PORTNOTE(section, text) 00806 //The following is what we want to do, but it doesn't work 00807 //#define PORTNOTE(section, text) #warning [PORTNOTE] section ": " text 00808 #else // __GNUG__ 00809 #define PORTNOTE(section, text) 00810 //The following is what we want to do, but it doesn't work 00811 //#define PORTNOTE(section, text) #pragma message( __LOCMSG__ section ": " text ) 00812 #endif // __GNUG__ 00813 #define PORTNOTETRACE(section, text) \ 00814 PORTNOTE(section,text) \ 00815 TRACE(_T("PORTNOTE[") _T(section) _T("]: ") _T(text)) 00816 #else //_DEBUG, SHOWPORTNOTE 00817 #define PORTNOTE(section, text) 00818 #define PORTNOTETRACE(section,text) 00819 #endif //_DEBUG, SHOWPORTNOTE 00820 00821 00822 #endif //INC_ERRORS