Actual parameter introspection for error logging

Discussion in 'Java' started by David Smith, Jul 11, 2003.

  1. David Smith

    David Smith Guest

    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.
     
    David Smith, Jul 11, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    0
    Views:
    985
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    9,618
    janne
    Sep 10, 2004
  3. Christoph Haas
    Replies:
    0
    Views:
    481
    Christoph Haas
    Jun 12, 2006
  4. Frederick Gotham

    Outside access to ACTUAL template parameter

    Frederick Gotham, Jul 1, 2006, in forum: C++
    Replies:
    2
    Views:
    338
    Robbie Hatley
    Jul 2, 2006
  5. Hellmut Weber

    Accessing the name of an actual parameter

    Hellmut Weber, Jan 26, 2010, in forum: Python
    Replies:
    1
    Views:
    277
    Alf P. Steinbach
    Jan 26, 2010
Loading...

Share This Page