Menu

[4640d3]: / Errorsys.prg  Maximize  Restore  History

Download this file

341 lines (259 with data), 8.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
/*
Generic Error System
Last change: TG 29 Jan 2011 1:00 pm
*/
#include "bpos.ch"
#include "error.ch"
#include "set.ch"
Procedure ErrorSys()
ErrorBlock( { |oError| ErrorMenu( oError ) } )
Return
Static Function ErrorMenu(oEr)
Local nErrLines,nActCount,cChoices,nErrTop,nErrBot,nChoice,cChoice,cErrScr,nIntense,;
cDevice,ccolor,bOldErr,cMsg,cErrWrnMsg,nLogFile
Local DosErr:={"Invalid function number","File not found","Path not found",;
"Too many open files","Access denied","Invalid handle","Memory",;
"Insufficient memory","Memory","Invalid environment","Invalid format",;
"Invalid access code","Invalid data","","Invalid drive",;
"Cannot remove directory","Not same device","No more files","Write-protect",;
"Unknown unit","Drive not ready","Unknown command","Data error (CRC)",;
"Bad request","Seek error","Unknown media type","Sector not found",;
"Printer out of paper","Write fault","Read fault","General failure",;
"Sharing violation","Lock violation","Invalid disk change","",;
"","","","","","","","","","","","","","","","","","Network name not found",;
"Network busy","","","Network adapter hardware error","Incorrect response from network",;
"Unexpected network error","Incompatible remote adapter","Print queue full",;
"Not enough space for print file","Print file deleted","Network name deleted",;
"Access denied","Network device type incorrect","Network name not found",;
"Network name limit exceeded","Network BIOS session limit exceeded",;
"Temporarily paused","Network request not accepted","","","","","","","","",;
"File already exists","","","","","Duplicate redirection",;
"Invalid password","Invalid parameter","Network device fault" }
local oPrinter
local aErrors := {} // Captures the callstack for output to the printer
local x // loop counter
local nHandle // File Handle to save the error
do case
case (oEr:genCode == EG_ZERODIV)
return ( 0 )
case (oEr:genCode == EG_OPEN) .and. oEr:osCode == 32 .and. (oEr:canDefault)
Neterr( TRUE )
return ( FALSE )
case oEr:genCode == EG_APPENDLOCK .and. oEr:canDefault
NetErr ( TRUE )
return ( FALSE )
endcase
/* if error occurs within this error-handler, handle with DuplError */
bOldErr:=ErrorBlock( {|oError| DuplError(oError)} )
nLogFile:=-1
cChoice:=' '
while cchoice != 'A'
ccolor:=setcolor('W/R')
cdevice:=set(_SET_DEVICE)
set device to screen
if oEr:genCode == EG_PRINT
nerrlines:=5
else
nerrlines:=6
endif
if oEr:genCode != EG_PRINT
if valtype( lvars( L_MAXROWS ) ) == nil
lvars( L_MAXROWS, 25 )
endif
nActCount := 2
while !empty( ProcName( nActCount ) ) .and. nErrLines <= 10
if procLine( nActCount ) != 0
nerrlines++
endif
nactcount++
enddo
if valtype(oEr:args)=='A'
if len(oEr:args) > 0
nErrLines++
endif
endif
nErrLines += if( oEr:filename == "", 0, 1 )
nErrLines += if( oEr:osCode != 0, 1, 0 )
endif
nerrtop := 5
nerrbot := min( nErrtop+nErrLines+5, 24-1 )
@ nErrTop,0 clear to nErrBot,60
@ nErrTop,0 to nErrBot,60 color 'B+/r'
do case
case oEr:severity==ES_CATASTROPHIC
cErrWrnMsg := 'Severe error'
case oEr:severity==ES_ERROR
cErrWrnMsg := 'Error'
case oEr:severity==ES_WARNING
cErrWrnMsg := 'Warning'
otherwise
cErrWrnMsg := 'Message'
endcase
if !Empty(oEr:subSystem)
cMsg := chr( 180 ) + SYSNAME + ' ' + cErrWrnMsg + chr( 195 )
@ nErrTop, 2 say cMsg
endif
aadd( aErrors, 'Error Diagnostics' )
cMsg := Ns( oEr:genCode ) + ': '+oEr:description + ' ( ' + alltrim( oEr:subsystem ) + '/' + Ns( oEr:subCode ) + ' ) '
@ row()+1, 2 say cMsg
aadd( aErrors, cMsg )
if oEr:osCode!=0
cMsg:='Dos error ' + Ns(oEr:osCode)
aadd( aErrors, cMsg )
@ row()+1,2 say cMsg + ': '
if oEr:oscode<=Len( DosErr ) .and. oEr:oscode>0
@ row(),Col() say DosErr[oEr:osCode]
endif
endif
if !oEr:operation==""
cMsg:='Operation attempted: '+oEr:operation
@ row()+1,2 say cMsg
aadd( aErrors, cMsg )
endif
if ValType(oEr:args)=='A'
if Len(oEr:args) > 0
cMsg:='Arguments: '+ErrDispArg(oEr:args[1])
@ row()+1,2 say cMsg
aadd( aErrors, cMsg )
if Len(oEr:args) > 1
cMsg:='& '+ErrDispArg(oEr:args[2])
@ row(),col() say cMsg
aadd( aErrors, cMsg )
endif
endif
endif
if oEr:filename != ""
cMsg:='Filename: ' + oEr:filename
@ row()+1,2 say cMsg
aadd( aErrors, cMsg )
endif
@ row()+1,2 say 'Called from: '
aadd( aErrors, 'Called from' )
nActCount := 2
while !( ProcName( nActCount ) == "" ) .and. nActCount <= 10
if procline( nActCount ) != 0
cMsg := padr( Procname( nActCount ), 20 ) + 'Line - ' + Ns( ProcLine( nActCount ) )
if row() < 20
@ row(),15 say cMsg
@ row()+1,Col() say ''
aadd( aErrors, cMsg )
endif
endif
nActCount++
enddo
if select() != 0
cMsg := 'File Selected->' + alias() + ' ' + Oddvars( SYSPATH )
@ nErrbot-2, 2 say cMsg
aadd( aErrors, cMsg )
endif
nIntense := set( _SET_INTENSITY , TRUE )
@ nErrbot-1, 2 say 'Notify Bluegum Software with this error.'
set( _SET_INTENSITY , nIntense )
nIntense:=set( _SET_INTENSITY , TRUE )
cChoices:={}
if (oEr:canRetry)
aadd( cchoices, { 'Retry', 'Retry the Operation' } )
endif
aadd( cchoices, { 'Print', 'Print these details for sending to ' + DEVELOPER } )
aadd( cchoices, { 'Abort', 'Exit from ' + SYSNAME } )
nchoice := MenuGen( cchoices, 12, 62, 'Select' )
set( _SET_INTENSITY , nIntense )
set( _SET_DEVICE , cDevice )
setcolor( ccolor )
do case
case ( oEr:canretry ) .and. nchoice = 1
Errorblock( bOldErr )
Box_Restore( cErrScr )
return TRUE
case ( !oEr:canRetry .and. nchoice = 1 ) .or. ( oEr:canRetry .and. nchoice = 2 )
dbcloseall() // Shut all files - will allow Error( 4 ) to print ok
set printer to ( trim( LVars( L_REPORT_NAME ) ) )
oPrinter := PrintCheck( "System Error Report" )
LP( oPrinter, DRAWLINE )
LP( oPrinter, BIGCHARS )
LP( oPrinter, SYSNAME + ' Build ' + BUILD_NO + ' Error Report #' + Ns( Sysinc( 'Fax', 'I', 1 ) ) )
LP( oPrinter, NOBIGCHARS )
LP( oPrinter, BIGCHARS )
LP( oPrinter, 'From ' + BPOSCUST)
LP( oPrinter, NOBIGCHARS )
LP( oPrinter, BIGCHARS )
LP( oPrinter, 'Time ' + time() + ' Ph.' + Bvars( B_PHONE ) )
LP( oPrinter, NOBIGCHARS )
LP( oPrinter, trim( version() ) + ' ' + Bvars( B_BRANCH ) )
LP( oPrinter, '' )
for x := 1 to len( aErrors )
LP( oPrinter, aErrors[ x ] )
next
// Printgraph( oPrinter ) // Adds the screen print to the mix
LP( oPrinter, '' )
LP( oPrinter, BIGCHARS )
LP( oPrinter, 'Please send me to Bluegum Software Email is ' + SUPPORT_EMAIL )
LP( oPrinter, NOBIGCHARS )
LP( oPrinter, BIGCHARS )
LP( oPrinter, 'Fax number ' + SUPPORT_FAX )
LP( oPrinter, NOBIGCHARS )
LP( oPrinter, '' )
LP( oPrinter, 'Comments ' + replicate( chr( 95 ), 60 ) )
LP( oPrinter, '' )
LP( oPrinter, ' ' + replicate( chr( 95 ), 60 ) )
LP( oPrinter, '' )
LP( oPrinter, 'Contact ' + replicate( chr( 95 ), 60 ) )
LP( oPrinter, '' )
LP( oPrinter, '____________________ < Bluegum Software Office Use >___________________' )
LP( oPrinter, '' )
LP( oPrinter, 'Date ____________ Copies To : ______________ Log Number __________' )
LP( oPrinter, '' )
LP( oPrinter, 'Actioned : Yes No Date___________ By _____________' )
oPrinter:EndDoc()
oPrinter:Destroy()
exit
otherwise
exit
endcase
enddo
// Try to save the error locally
nHandle = HB_FTempCreate( OddVars( SYSPATH ) + 'errors' )
for x = 1 to len( aErrors )
Fwrite( nHandle, aErrors[ x ] + CRLF )
next
FClose( nHandle )
setCursor( 1 ) // don't leave them in DOS without a cursor!
ErrorLevel( 0 )
quit // We are out of here
Return FALSE // superfluous return required to compile without warning
*
Static Function ErrDispArg(arg)
Local cStr
do case
case ValType(arg)=='A'
cStr:='(Array) '
case ValType(arg)=='B'
cStr:='(Block) '
case ValType(arg)=='C'
cStr:='(C) "'+arg+'" '
case ValType(arg)=='D'
cStr:='(D) '+dtoc(arg)+' '
case ValType(arg)=='L'
cStr:='(L) .'+if(arg,'T','F')+'. '
case ValType(arg)=='M'
cStr:='(M) "'+arg+'" '
case ValType(arg)=='N'
cStr:='(N) '+AllTrim(Str(arg))+' '
case ValType(arg)=='O'
cStr:='(Object) '
otherwise
cStr:='(NIL) '
endcase
Return cStr
*
Static Function DuplError( oEr )
set print off
set console on
? "Error (" + Trim( oEr:description ) + ") at " + Trim( ProcName( 2 ) ) + ' (' + Ns( ProcLine( 2 ) ) + ')'
? Procname( 1 ) + ' ' + Ns( Procline( 1 ) )
? Procname( 0 ) + ' ' + Ns( Procline( 0 ) )
?
wait
Errorlevel( 0 )
quit
return (FALSE)