redirecting errors

B

bitshit

Hi,

Is it possible to redirect java errors to post to a url? I have a generic
library that some third party classes extend. When these third party classes
generate errors/crash i'd like to post these errors to a script instead of
the jvm printing it standard to the console... it concerns applets, the
third party applets extend a super class form my library where I migth be
able to set such a redirect?

Thanks!
 
J

jan V

Is it possible to redirect java errors to post to a url?

Check out System.setErr(PrintStream) and System.setOut(PrintStream), taking
particular note that both methods are SecurityManager-restricted (I'm
assuming this can be solved by signing the applets). If you create a fancy
PrintStream subclass which does your URL post stuff, you'd be home and dry,
no?
 
O

Oliver Wong

bitshit said:
Hi,

Is it possible to redirect java errors to post to a url? I have a generic
library that some third party classes extend. When these third party
classes generate errors/crash i'd like to post these errors to a script
instead of the jvm printing it standard to the console... it concerns
applets, the third party applets extend a super class form my library
where I migth be able to set such a redirect?

I think this kind of stuff is usually done via exception handling,
except it assumes that you are invoking the methods which are generating the
exception, and not the other way around. (Obligatory Slashdot reference: In
Soviet Russia, methods generating exceptions invokes you!)

You could try inverting the call hiearchy, by forcing the third party
code to pass you something like a method pointer or delegate (or something
like the Command design pattern), and then your library code calls this
delegate, and catch any exception it throws, and post to whatever URL you
want.

- Oliver
 
R

Roedy Green

Is it possible to redirect java errors to post to a url? I have a generic
library that some third party classes extend. When these third party classes
generate errors/crash i'd like to post these errors to a script instead of
the jvm printing it standard to the console... it concerns applets, the
third party applets extend a super class form my library where I migth be
able to set such a redirect?

Remote I/O is still in the stone age. It is not like writing to a
file. There is nothing at the other end to receive it. You have to
deal with the various exceptions that may occur. Likely the sandbox
will clamp down on you unless your Applet is signed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top