Actual parameter introspection for error logging

D

David Smith

Hello,

I'd like to write a detailed log following an Exception, that includes
listing the field values of each parameter that was in the list of
actual parameters.

For example, imagine the following methods:

public void callingMethod() {
faultyMethod ("Hello", 99);
}

public void faultyMethod (String s, int i) {
throw new Exception();
}

While I'm in this method body, can I use reflection to get a
collection of all the actual parameters somehow, so that I can put a
String representation of them as the message into the Exception? This
would be easier than for each method manually writing the required
code to process the actual parameters.

So in this case, the message would be something like "s=Hello – i=99".
User-defined objects can easily be introspected and the fields
printed.

Thanks,
David.
 

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

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top