lhamey@mqccsunb.mqcc.mq.oz.au (Len Hamey) (08/27/90)
Whilst trying to determine why a particular PS file would not print,
I developed the following error trap routine. I offer it to the net
freely (you get what you pay for, usually). I would be interested
in better/improved solutions to the same problem.
% Catch PS error and print out potentially useful info.
% If your PS code fails, just include this at start. Upon failure
% it dumps the current (incomplete) page then prints out two pages
% of error info.
/ErrorStringBuffer 1000 string def
errordict /handleerror
{ showpage
% showpage also initializes graphics state.
/Times-Roman findfont 12 scalefont setfont
{
72 680 moveto
(Error encountered: ) show
$error /errorname get ErrorStringBuffer cvs show
72 660 moveto (Command in error: ) show
$error /command get ErrorStringBuffer cvs show
72 640 moveto
vmstatus (Virtual memory: max: ) show ErrorStringBuffer cvs show
( used: ) show ErrorStringBuffer cvs show
( level: ) show ErrorStringBuffer cvs show
72 600 moveto
(Context:) show
1 1 5
{ pop currentpoint 16 sub exch pop 108 exch moveto
(\%stdin) (r) file ErrorStringBuffer readline exch show
% Status_of_readline_false_if_end_of_file
not { exit } if
} for
currentpoint 20 sub exch pop 72 exch moveto
(Execution Stack:) show
$error /estack get
length 1 sub % n-1
dup 100 sub dup % n-1 n-101 n-101
0 lt % n-1 n-101 n-101<0
{ 0 } { dup } ifelse % n-1 n-101 max(0,n-101)
exch pop -1 exch % n-1 -1 max(0,n-101)
{ currentpoint 16 sub exch pop 108 exch moveto
$error /estack get exch get ErrorStringBuffer cvs show
} for
} stopped pop
showpage
{
72 680 moveto
(Operand Stack:) show
$error /ostack get
length 1 sub % n-1
dup 100 sub dup % n-1 n-101 n-101
0 lt % n-1 n-101 n-101<0
{ 0 } { dup } ifelse % n-1 n-101 max(0,n-101)
exch pop -1 exch % n-1 -1 max(0,n-101)
{ currentpoint 16 sub exch pop 108 exch moveto
$error /ostack get exch get % Item from operand stack
dup type ErrorStringBuffer cvs show (: ) show
ErrorStringBuffer cvs show
} for
} stopped pop
showpage
} put
% The following is a test example of an error...
4 5 6 [1 2 3] (Fred was here) notandexistingoperator morebadstuff
This is a line of text
There is a little more
% A comment line
There follows more
and more
Len Hamey
Macquarie Universityshiva@well.sf.ca.us (Kenneth Porter) (09/06/90)
An error handler should be available from the ps-file-server: mail ps-file-server@adobe.com send programs ehandler.ps This is also available on the Adobe tools diskette, which I think costs $6 and also contains a page timer (in PostScript) and an AFM parser (in C).