diff -rc /NextDeveloper/Examples/Yap/YapApp.h Yap/YapApp.h
*** /NextDeveloper/Examples/Yap/YapApp.h	Mon Aug 28 18:44:39 1989
--- Yap/YapApp.h	Mon Feb 19 14:47:08 1990
***************
*** 9,18 ****
--- 9,22 ----
      id outputWindow;
      id openPanel;
      id savePanel;
+     id errorWindow;
+     id errorText;
      NXSize maxWindowSize;    
  }
  
  - setOutputWindow:anObject;
+ - setErrorWindow:anObject;
+ - setErrorText:anObject;
  - setInfoItem:anObject;
  
  - newDocument:sender;
***************
*** 31,35 ****
--- 35,41 ----
  - savePanel;
  - outputView;
  - outputWindow;
+ - errorWindow;
+ - errorText;
  
  @end
diff -rc /NextDeveloper/Examples/Yap/YapApp.m Yap/YapApp.m
*** /NextDeveloper/Examples/Yap/YapApp.m	Mon Aug 28 19:31:54 1989
--- Yap/YapApp.m	Mon Feb 19 14:47:47 1990
***************
*** 48,53 ****
--- 48,63 ----
      return (outputWindow);
  }
  
+ - errorWindow
+ {
+     return (errorWindow);
+ }
+ 
+ - errorText
+ {
+     return (errorText);
+ }
+ 
  // Here we have a handle to the output window, created in IB. We create
  // the scroll and the yap output views and add them to this window.
  
***************
*** 71,76 ****
--- 81,100 ----
  
      [outputWindow setDelegate:self]; // So we can get windowWillResize:toSize:
      [outputWindow display];
+ 
+     return self;
+ }
+ 
+ - setErrorWindow:anObject
+ {
+     errorWindow = anObject;
+ 
+     return self;
+ }
+ 
+ - setErrorText:anObject
+ {
+     errorText = anObject;
  
      return self;
  }
diff -rc /NextDeveloper/Examples/Yap/YapOutput.m Yap/YapOutput.m
*** /NextDeveloper/Examples/Yap/YapOutput.m	Tue Jul 25 01:33:44 1989
--- Yap/YapOutput.m	Wed Apr 25 16:40:41 1990
***************
*** 15,20 ****
--- 15,21 ----
  #import <appkit/nextstd.h>
  #import <appkit/Bitmap.h>
  #import <appkit/Panel.h>
+ #import <appkit/ScrollView.h>
  #import <appkit/Text.h>
  #import <appkit/Window.h>
  #import <dpsclient/wraps.h>
***************
*** 144,149 ****
--- 145,151 ----
          NXPrintf (psStream, "%%Temporary file created by Yap.\n");
          NXPrintf (psStream, "/yapwidth %f def /yapheight %f def "
  		      "/showpage {} def /yaptime usertime def\n"
+ 		      "/letter {} def /legal {} def /note {} def\n"
  		      "%f %f scale\n", 
                        bounds.size.width, bounds.size.height, scaling, scaling);
          [textObj writeText:psStream];
***************
*** 165,189 ****
    
      errorOccured = NO;
      SaveYapState ();
  
      NX_DURING {
  	PSrun (psFileName);
! 	NXPing ();             // This does not return until PSrun() is done
! 	GetUserTime (&utime);  // We don't bother with this if there are errors
  	sprintf (status, "Yap Postscript Output (Execution Time %d ms)", utime);
      } NX_HANDLER {
  	errorOccured = YES;
  	WritePostScriptError (status, STATUSLENGTH, &NXLocalHandler);
!     } NX_ENDHANDLER
  
      RestoreYapState ();
      [cache unlockFocus];
      [self display];
- 
      unlink (psFileName);
  
      [[self window] setTitle:status];
      
      return self;
  }
  
--- 167,222 ----
    
      errorOccured = NO;
      SaveYapState ();
+     EnableRecordstacks ();
  
      NX_DURING {
  	PSrun (psFileName);
! 	NXPing ();             /* This does not return until PSrun() is done */
! 	GetUserTime (&utime);  /* We don't bother with this if there are errors */
  	sprintf (status, "Yap Postscript Output (Execution Time %d ms)", utime);
+ 
      } NX_HANDLER {
  	errorOccured = YES;
  	WritePostScriptError (status, STATUSLENGTH, &NXLocalHandler);
!     } NX_ENDHANDLER;
  
+     if (errorOccured) {
+ 	extern NXStream *globalErrorStream;
+ 	extern void LogToGlobalErrorStream();
+ 	DPSContext ctxt = DPSGetCurrentContext();
+         int lenostack;
+ 	Text *errorView;
+ 	DPSTextProc oproc;
+ 
+ 	globalErrorStream = NXOpenMemory(NULL, 0, NX_READWRITE);
+ 	NXPrintf(globalErrorStream, "%s\n", status);
+ 
+ 	NXPrintf(globalErrorStream, "STACK:\n");
+ 
+ 	oproc = DPSSetTextProc(ctxt, LogToGlobalErrorStream);
+ 
+ 	DumpOstack();
+ 
+ 	DPSWaitContext(ctxt);
+ 	(void)DPSSetTextProc(ctxt, oproc);
+ 	NXSeek(globalErrorStream, 0L, NX_FROMSTART);
+ 
+ 	errorView = [[NXApp errorText] docView];
+ 	[errorView readText:globalErrorStream];
+ 	NXCloseMemory(globalErrorStream, NX_FREEBUFFER);
+     }
+ 
      RestoreYapState ();
      [cache unlockFocus];
      [self display];
      unlink (psFileName);
  
      [[self window] setTitle:status];
      
+     if (errorOccured) {
+ 	[[NXApp errorWindow] orderFront:self];
+     }
+ 
      return self;
  }
  
diff -rc /NextDeveloper/Examples/Yap/YapWrap.psw Yap/YapWrap.psw
*** /NextDeveloper/Examples/Yap/YapWrap.psw	Mon Jul 17 20:46:32 1989
--- Yap/YapWrap.psw	Wed Apr 25 13:49:46 1990
***************
*** 11,16 ****
--- 11,43 ----
  
  defineps RestoreYapState ()
    clear  %Empty the stack
+   cleardictstack
    userdict /yapsavedstate known {yapsavedstate restore} if
  endps
  
+ /*
+  * Error reporting routines by jgm
+  */
+ 
+ #include <streams/streams.h>
+ 
+ NXStream *globalErrorStream;
+ 
+ void LogToGlobalErrorStream(ctxt, buf, count)
+ DPSContext ctxt;
+ char *buf;
+ long unsigned int count;
+ {
+     NXWrite(globalErrorStream, buf, count);
+ }
+ 
+ defineps EnableRecordstacks()
+   $error /recordstacks true put
+ endps
+ 
+ defineps DumpOstack()
+   $error /ostack get aload length { == } repeat
+   (\nEXEC STACK:\n) print
+   $error /estack get aload length { == } repeat
+   flush
+ endps
