Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!munnari.oz.au!metro!macuni!lhamey@mqccsunb.mqcc.mq.oz.au From: lhamey@mqccsunb.mqcc.mq.oz.au (Len Hamey) Newsgroups: comp.lang.postscript Subject: PostScript Error Dump Routine (free) Keywords: handleerror Message-ID: <432@macuni.mqcc.mq.oz> Date: 27 Aug 90 04:31:59 GMT Sender: news@macuni.mqcc.mq.oz Organization: Macquarie University, Sydney Lines: 74 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 University