#include <errors.h>
Public Member Functions | |
Error () | |
~Error () | |
Static Public Member Functions | |
static BOOL | IsUserName (const char *wanted) |
static void | SetUserName (wxString User) |
static HRESULT | ErrIDToHRESULT (UINT32 ErrID) |
Convert our ErrID's to HRESULTS if we're not interested return S_OK. | |
static HRESULT | GetRalphError () |
ERROR1 - No local reporting -pass the mapped Error code to the harness ERROR2 - Report the Error locally - don't pass to handler ERROR3 - Report as ERROR2's - won't occur in retails -. | |
static void | SetError (UINT32 number, const TCHAR *errstring, UINT32 module) |
Called before exiting a routine that failed, this function sets up the static variables which allow the calling routine to see what the error was. If the errstring parameter is passed, the module UINT32 is stored, but not used. This form of the function would usually be used for routines which want to build up an error string on the fly. If the errstring is absent, the routine uses the UINT32 to identify the module, and loads a string from the appropriate resources. | |
static void | SetError (UINT32 number, UINT32 module=0) |
static void | SetErrorTool (UINT32 number, UINT32 toolid) |
static void | SetErrorSerious (const TCHAR *) |
static void | ClearError () |
Resets the error system to "no current error". | |
static TCHAR * | GetErrorString () |
Notes the threading in or out of rendering (i.e. whether the program is somewhere within a render loop). Each RenderThreadIn should be paired with a RenderThreadOut and placed around rendering code. They may be nested. RenderThreadReset notes an abnormal termination of the thread (for instance an exception). Whilst in render threads, errors are handled slightly differently. Hence the need to know. Tells the caller whether or not Camelot is in a render thread. If so, if an error occurs, it is likely to be (a) nasty, and (b) repeated many times, so more forceful action is taken to get rid of it. Gets the string associated with the last error from the static error variables. Usually used by an operation to report why the operation failed. | |
static UINT32 | GetErrorNumber () |
If a function returns failure, this function will read the error number. This is usually associated with a resource of some kind - in Win16 it will be the 16bit resource ID, in RISC OS it will be a 32bit resource ID, etc. There is always an associated string (reached by GetErrorString) so routines wanting to report the error do not need to do any nasty resource loading. | |
static UINT32 | GetRalphErrorNumber () |
As GetERrorNumber EXCEPT this returns the ralph copy of ErrorID that is not cleared in SetSeriousError(). | |
static UINT32 | GetErrorModule () |
Mainly for debugging - the UINT32 is a unique identifier which will tell a programmer which module generated the last error. This will never be visible to a user. | |
static void | RenderThreadIn () |
static void | RenderThreadOut () |
static void | RenderThreadReset () |
static BOOL | IsInRenderThread () |
static void | DirectStatus (BOOL=FALSE) |
static void | MarkError (UINT32 LineNumber, const char *Filename) |
Used to 'remember' where an error ocurred. Cannot be done with extra params to InternalSetError due to vararg strangeness. The function is declared inline on retail builds. Scope: Public Static. | |
static void CDECL | XSetErrorC () |
Do NOT call directly. Sets up the internal error Scope: Public Static. | |
static void CDECL | XSetError (const TCHAR *fmt,...) |
Do NOT call directly. Called via the ERROR2xx macros. In debug builds, puts up an ensure box. In all builds, sets an error. Do NOT put 's or 's on the end. Scope: Public Static. | |
static void CDECL | XSetError (UINT32,...) |
Do NOT call directly. Called via the ERROR1xx macros. Scope: Public Static. | |
static void CDECL | ReleaseTrace (LPCTSTR,...) |
static void CDECL | TraceUser (const char *, LPCTSTR,...) |
static void CDECL | TraceAll (LPCTSTR,...) |
static void CDECL | TraceTime (TCHAR *) |
static void | DumpStack (UINT32 frames=0) |
Dumps the stack Scope: Public Static. | |
Static Public Attributes | |
static UINT32 | ErrorBoxRecurse = 0 |
Static Private Member Functions | |
static void | TraceWrite (const TCHAR *buf, va_list args) |
static void | FixFormat (const TCHAR *fmt, TCHAR *fmt2) |
Static Private Attributes | |
static UINT32 | ErrorID = 0 |
static UINT32 | RalphErrorID = 0 |
static UINT32 | ModuleID = 0 |
static TCHAR | ErrorString [256] |
To display a dialog that gives an error message of some description. Up to 3 buttons can be defined for the user to select. It should be used when an error occurs that the user could make a decision about eg. Camelot failed to save the file, so give them the option to give up, try again or try a new filename/path etc. If ErrorMsg is zero, the box will use the last error returned by a function with the RETURNERROR macro. ToolInformError takes an additional parameter on the front of the Tool ID. ModuleInformError takes a module ID. Both of these will try to find the strings used for errors and buttons in the owner module first, then the main .exe file. These are all in-line function stubs which call InformGeneral. The equivalent routines with 'Serious' in their name are the equivalent of those without except that they pass ERRORTYPE_SERIOUS and not ERRORTYPE_ERROR It's also worth noting tat these are just inline functions that call InformGeneral and they live solely in Errors.h To display a dialog that gives a warning message of some description. Up to 3 buttons can be defined for the user to select. If ErrorMsg is zero the error string will be taken from the static Error variables, bringing up the last error that was set by a function calling RETURNERROR. | |
static UINT32 | RenderThread = 0 |
static UINT32 | LastErrorLine |
static const char * | LastErrorFile = "Unknown.File" |
static wxString | UserName |
Classes | |
class | StackWalker |
Definition at line 487 of file errors.h.
|
Definition at line 519 of file errors.h. 00520 { 00521 ErrorString[0] = 0; 00522 RalphErrorID =ErrorID = ModuleID = 0; 00523 }
|
|
|
|
Resets the error system to "no current error".
Definition at line 1024 of file errors.cpp. 01025 { 01026 TRACEUSER( "Chris", _T("Clear Error now \n") ); 01027 RalphErrorID = ErrorID = ModuleID = 0; 01028 ErrorString[0] = 0; 01029 01030 // Added 15/2/95 so that the function does as it name suggests and actually does clear 01031 // the current error completely from the system rather than just clearing out the error 01032 // id and the error string. 01033 ErrorHasBeenReported = TRUE; 01034 ErrStatus = ERRORSTAT_NONE; 01035 }
|
|
|
|
Dumps the stack Scope: Public Static.
Definition at line 1792 of file errors.cpp. 01793 { 01794 #ifdef _DEBUG 01795 #if !defined(__WXMAC__) && !defined(__FreeBSD__) 01796 Error::StackWalker s; 01797 s.Walk(frames); 01798 #else 01799 TRACE( _T("Request to dump stack not supported on this platform") ); 01800 #endif 01801 #endif 01802 }
|
|
Convert our ErrID's to HRESULTS if we're not interested return S_OK.
Definition at line 188 of file errors.cpp. 00189 { 00190 #ifdef RALPH 00191 return GetHRESULTFromID(ErrID); 00192 #endif 00193 return S_OK; 00194 }
|
|
|
|
Mainly for debugging - the UINT32 is a unique identifier which will tell a programmer which module generated the last error. This will never be visible to a user.
Definition at line 739 of file errors.h. 00740 { 00741 return ModuleID; 00742 }
|
|
If a function returns failure, this function will read the error number. This is usually associated with a resource of some kind - in Win16 it will be the 16bit resource ID, in RISC OS it will be a 32bit resource ID, etc. There is always an associated string (reached by GetErrorString) so routines wanting to report the error do not need to do any nasty resource loading.
Definition at line 714 of file errors.h. 00715 { 00716 return ErrorID; 00717 }
|
|
Notes the threading in or out of rendering (i.e. whether the program is somewhere within a render loop). Each RenderThreadIn should be paired with a RenderThreadOut and placed around rendering code. They may be nested. RenderThreadReset notes an abnormal termination of the thread (for instance an exception). Whilst in render threads, errors are handled slightly differently. Hence the need to know. Tells the caller whether or not Camelot is in a render thread. If so, if an error occurs, it is likely to be (a) nasty, and (b) repeated many times, so more forceful action is taken to get rid of it. Gets the string associated with the last error from the static error variables. Usually used by an operation to report why the operation failed.
Definition at line 664 of file errors.h. 00665 { 00666 return ErrorString; 00667 }
|
|
ERROR1 - No local reporting -pass the mapped Error code to the harness ERROR2 - Report the Error locally - don't pass to handler ERROR3 - Report as ERROR2's - won't occur in retails -.
Definition at line 208 of file errors.cpp. 00209 { 00210 00211 UINT32 Err = Error::GetRalphErrorNumber(); 00212 wxString ErrStr( Error::GetErrorString() ); 00213 HRESULT hr = S_OK; 00214 00215 // ERROR2's 3's 00216 if(Err==0) 00217 { 00218 if(!ErrStr.IsEmpty()) 00219 { 00220 #if defined(_DEBUG) && defined(__WXMSW__) 00221 MessageBox(NULL,ErrStr,_T("Error"),MB_OK); 00222 #endif 00223 // make sure we clear ERROR2's 'cause we report them now 00224 Error::ClearError(); 00225 } 00226 } 00227 00228 //ERROR1 00229 if(Err!=0) 00230 { 00231 // Do Mapping 00232 hr = ErrIDToHRESULT(Err); 00233 00234 } 00235 // ERROR 2's 3's 00236 if(Err==0) 00237 { 00238 if(!ErrStr.IsEmpty()) 00239 hr = RALPH_E_INTERNAL; 00240 } 00241 00242 return hr; 00243 }
|
|
As GetERrorNumber EXCEPT this returns the ralph copy of ErrorID that is not cleared in SetSeriousError().
Definition at line 685 of file errors.h. 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 }
|
|
Definition at line 554 of file errors.h. 00554 { return ( RenderThread != 0 ); }
|
|
|
|
Used to 'remember' where an error ocurred. Cannot be done with extra params to InternalSetError due to vararg strangeness. The function is declared inline on retail builds. Scope: Public Static.
Definition at line 558 of file errors.h.
|
|
Definition at line 1186 of file errors.cpp. 01187 { 01188 TCHAR buf[256]; 01189 va_list marker; 01190 va_start( marker, fmt ); 01191 camVsnprintf( buf, 256, fmt, marker ); 01192 01193 #if defined( __WXMSW__ ) 01194 OutputDebugString( buf ); 01195 #elif defined( __WXGTK__ ) 01196 camPrintf( buf ); 01197 #else 01198 #pragma error( "Not support on this architechure" ) 01199 #endif 01200 01201 va_end( marker ); 01202 }
|
|
Definition at line 551 of file errors.h. 00551 { RenderThread++; }
|
|
Definition at line 552 of file errors.h. 00552 { RenderThread--; }
|
|
Definition at line 553 of file errors.h. 00553 { RenderThread = 0; }
|
|
Definition at line 963 of file errors.cpp. 00964 { 00965 static TCHAR BASED_CODE LastResort[] = _T("Cannot perform SetError (2)"); 00966 // We now check for a real recursive call. Should only happen if we can't get translate 00967 // an ID to an error string. Perhaps if we're really low on memory. We must then set the 00968 // minimum acceptable error string... 00969 if (InSetError) 00970 { 00971 TRACE(_T("SetError really has been called recursively (2)\n")); 00972 ErrorID = _R(IDE_EX_BADOP); // should have it's own, but... 00973 ErrStatus = ERRORSTAT_TEXT; 00974 ErrorHasBeenReported=FALSE; 00975 ModuleID = module; 00976 camStrcpy( ErrorString, LastResort ); 00977 return; 00978 } 00979 InSetError++; 00980 if (!ErrorHasBeenReported) 00981 { 00982 // ENSURE(FALSE, "Recursive SetError call"); IMHO this is pointless - Alex 00983 TRACE( _T("SetError called twice: ID = %u Module = %u\n"), number, module); 00984 InSetError--; 00985 return; 00986 } 00987 RalphErrorID = ErrorID = number; 00988 ModuleID = module; 00989 ErrorString[0] = 0; 00990 ErrStatus = ERRORSTAT_ID; 00991 ErrorHasBeenReported = FALSE; 00992 if (!SmartLoadString(module, ErrorID, ErrorString, 256 * sizeof(TCHAR)) ) 00993 { 00994 camSnprintf( ErrorString, 256, _T("Error Number %u from module ID %u"), ErrorID, ModuleID ); 00995 } 00996 00997 TRACE( _T("Setting error: ID = %d: \"%s\"\n"), ErrorID, ErrorString); 00998 InSetError--; 00999 }
|
|
Called before exiting a routine that failed, this function sets up the static variables which allow the calling routine to see what the error was. If the errstring parameter is passed, the module UINT32 is stored, but not used. This form of the function would usually be used for routines which want to build up an error string on the fly. If the errstring is absent, the routine uses the UINT32 to identify the module, and loads a string from the appropriate resources.
Definition at line 912 of file errors.cpp. 00913 { 00914 static TCHAR BASED_CODE LastResort[] = wxT("Cannot perform SetError (1)"); 00915 // We now check for a real recursive call. Should only happen if we can't get translate 00916 // an ID to an error string. Perhaps if we're really low on memory. We must then set the 00917 // minimum acceptable error string... 00918 if (InSetError) 00919 { 00920 TRACE(_T("SetError really has been called recursively (1)\n")); 00921 RalphErrorID =ErrorID = _R(IDE_EX_BADOP); // should have it's own, but... 00922 ErrStatus = ERRORSTAT_TEXT; 00923 ErrorHasBeenReported=FALSE; 00924 ModuleID = module; 00925 camStrcpy( ErrorString, LastResort ); 00926 return; 00927 } 00928 InSetError++; 00929 00930 // Andy has stubbed this code out as it caused problems, e.g. 00931 // 'save changes' dialog after a GP fault had been caught made the dialog have the 'save 00932 // changes' buttons, with the GP fault text 00933 #if 0 00934 if (!ErrorHasBeenReported) 00935 { 00936 // ENSURE(FALSE, "Recursive SetError call"); IMHO this is pointless - Alex 00937 TRACE( _T("SetError called twice: ID = %u: %s\n"), number, errstring); 00938 InSetError--; 00939 return; 00940 } 00941 #endif 00942 00943 RalphErrorID = ErrorID = number; 00944 camStrcpy(ErrorString, errstring); 00945 ModuleID = module; 00946 ErrStatus = ERRORSTAT_TEXT; 00947 ErrorHasBeenReported = FALSE; 00948 TRACE( _T("Setting error: ID = %u: %s\n"), ErrorID, ErrorString); 00949 InSetError--; 00950 }
|
|
Definition at line 952 of file errors.cpp. 00953 { 00954 // this must succeed. In particular it must NOT cause any other errors or ENSUREs 00955 ErrorID = 0; 00956 ModuleID = 0; 00957 InSetError = 0; 00958 ErrStatus = ERRORSTAT_TEXT; 00959 ErrorHasBeenReported = FALSE; 00960 camStrcpy( ErrorString, errstring ); 00961 }
|
|
Definition at line 1002 of file errors.cpp. 01003 { 01004 Error::SetError(number, Tool::GetModuleID(toolID)); 01005 }
|
|
Definition at line 527 of file errors.h. 00527 { UserName = User; }
|
|
Definition at line 589 of file errors.h.
|
|
Definition at line 590 of file errors.h.
|
|
Definition at line 588 of file errors.h.
|
|
|
|
Do NOT call directly. Called via the ERROR1xx macros. Scope: Public Static.
Definition at line 1400 of file errors.cpp. 01401 { 01402 01403 01404 if ( (errID==FALSE) || (errID==TRUE) ) 01405 { 01406 // someone probably used the wrong macro parameters e.g. TRUE and FALSE instead of ID 01407 // This call will set an _R(IDE_INTERNAL_ERROR) for us 01408 ERROR2RAW( "ERROR1 macro used with invalid parameters" ); 01409 return; 01410 } 01411 01412 TCHAR buf[256]; 01413 01414 va_list marker; 01415 01416 va_start( marker, errID ); 01417 01418 String_256 result; 01419 01420 // load the format string as a resoure (note no module ID yet) 01421 if (!SmartLoadString(0, errID, buf, sizeof(buf))) 01422 { 01423 camSnprintf( buf, 256, wxT("Error<%u>"), errID ); // keep inline 01424 } 01425 01426 // now do _MakeMsg type formatting 01427 result.CCvsprintf(buf, marker); 01428 01429 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 01430 // Set the help context. 01431 SetNextMsgHelpContext(errID); 01432 #endif 01433 // ralph needs this so that he can map the ID to a HRESULT before passing it 01434 // back to a harness 01435 TRACEUSER( "Chris", wxT("oOoOo Ralph Set Error %d \n"), RalphErrorID ); 01436 01437 RalphErrorID =errID; 01438 01439 // and copy result into ErrorString 01440 SetErrorSerious( result ); 01441 01442 // trace output because SetErrorSerious doesn't bother 01443 TRACE( wxT("Setting error: ID = %d: \"%s\"\n"), errID, ErrorString); 01444 01445 // then tidy up 01446 va_end( marker ); 01447 01448 ResetWhere(); 01449 }
|
|
Do NOT call directly. Called via the ERROR2xx macros. In debug builds, puts up an ensure box. In all builds, sets an error. Do NOT put
Definition at line 1264 of file errors.cpp. 01265 { 01266 #ifdef _DEBUG 01267 TCHAR buf[256]; 01268 #if 0 != wxUSE_UNICODE 01269 TCHAR fmt2[MAXERRORFORMATLENGTH]; 01270 FixFormat(fmt, fmt2); 01271 #else 01272 const TCHAR * fmt2=fmt; 01273 #endif 01274 01275 va_list marker; 01276 va_start( marker, fmt ); 01277 camVsnprintf( buf, 256, fmt2, marker ); 01278 va_end( marker ); 01279 01280 // in debug builds we put up an ensure box 01281 EnsureFailedLine( buf, LastErrorFile, LastErrorLine ); // put up box 01282 01283 #endif 01284 01285 XSetErrorC(); 01286 return; 01287 }
|
|
Do NOT call directly. Sets up the internal error Scope: Public Static.
Definition at line 1378 of file errors.cpp. 01379 { 01380 TCHAR buf[256]; 01381 // the error we set features a coded version of where the problem was 01382 CalcInternalMessage( buf, LastErrorLine, String_256( LastErrorFile ) ); 01383 SetErrorSerious( buf ); 01384 ResetWhere(); 01385 return; 01386 }
|
|
|
|
|
|
To display a dialog that gives an error message of some description. Up to 3 buttons can be defined for the user to select. It should be used when an error occurs that the user could make a decision about eg. Camelot failed to save the file, so give them the option to give up, try again or try a new filename/path etc. If ErrorMsg is zero, the box will use the last error returned by a function with the RETURNERROR macro. ToolInformError takes an additional parameter on the front of the Tool ID. ModuleInformError takes a module ID. Both of these will try to find the strings used for errors and buttons in the owner module first, then the main .exe file. These are all in-line function stubs which call InformGeneral. The equivalent routines with 'Serious' in their name are the equivalent of those without except that they pass ERRORTYPE_SERIOUS and not ERRORTYPE_ERROR It's also worth noting tat these are just inline functions that call InformGeneral and they live solely in Errors.h To display a dialog that gives a warning message of some description. Up to 3 buttons can be defined for the user to select. If ErrorMsg is zero the error string will be taken from the static Error variables, bringing up the last error that was set by a function calling RETURNERROR.
|
|
|
|
|
|
|
|
|
|
|
|
|