When an error occurs in run() or runUntilHalt(), they throw an
exception.  If you're writing Java main(), it's up to you to catch
those exceptions and send them to where you want them to go; otherwise
they propagate to the default top level handler which prints them to
the screen. 

This is the catch block that jess.Main uses after the main loop --
you'll need to use something like this. Note that by assigning the
WSTDERR router, you've already arranged for getErrStream() to returns
something connected to your window.

 } catch (JessException re) {
     if (re.getNextException() != null) {
         m_rete.getErrStream().write(re.toString());

         m_rete.getErrStream().write("\nNested exception is:\n");
         m_rete.getErrStream().println(re.getNextException().getMessage());
         re.getNextException().printStackTrace(m_rete.getErrStream());

     } else
         re.printStackTrace(m_rete.getErrStream());
 }


Of course -- you could just use jess.Console, if you're only
experimenting. 


I think [EMAIL PROTECTED] wrote:
> Hello,
> 
> I have an error in my program that causes my wimpy DOS window to overflow.  
> Since the DOS window will not let me scroll up to see the cause, I am trying 
> to output the error message to a textarea.   I get all the normal output, but 
> the error message does not show up in the textarea.  Here's my code:
> 
> import jess.*;
> import java.io.*;
> import java.awt.TextArea;
> import jess.awt.*;
> import java.awt.*;
> 
>     
> public class RobotMain
> {
>     public static void main(String[] argv) throws JessException
>     {
>         TextArea ta = new TextArea(20,80);
>         TextAreaWriter taw = new TextAreaWriter(ta);
>         Frame a = new Frame("Output");
>         a.add(ta);
>         a.show();
>         Rete r = new Rete();
>         r.addOutputRouter("WSTDOUT",taw);
>         r.addOutputRouter("WSTDERR",taw);
>         r.addOutputRouter("t",taw);
>         
>         r.executeCommand("(batch robot.clp)");
>                 
>         r.runUntilHalt();                   
>     }
>     
> }
> 
> Thanks
> Matt
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to