Java vanishing Exception message... surpressed exception maybe?

49 views Asked by At

Writing in Java. This is a problem that is befuddling me, and it also feels right out of my grasp. Here is a little pseudo-code in a try block and real code in the catch block.

try {

    // 83 lines of code that do a bunch of stuff, with methods that call other
    // methods which call which call other methods

} catch (Exception e) {
    logger.writeLogError("*********FAILURE BEGIN*********\n");
    e.printStackTrace();
    logger.writeLogError("*********FAILURE END*********\n");
    String errorMesg;

    // Any downstream method that throws an exception without a message
    // will have e.getMessage == null
    if(e.getMessage() == null) {
        // This is for an unanticipated exception.  
        // The stack trace should give more information.
        errorMesg = "Skipped.  Unknown exception.  Check logs for string Exception thrown: ";
    } else {
        errorMesg = "Skipped. " + e.getMessage();
    }
}

The variable "errorMesg" is written to a database table. It is not printed to the log. So here's the problem. Something is happening somewhere deep in the bowels of the code that is throwing a NullPointerException. This is what we see in the log file.

2022-10-25 14:06:28,583 ERROR [com.fdc.gibson.services.orderentry.ThisClass] (WorkerThread#39[192.168.136.172:55767]) ********FAILURE BEGIN********

2022-10-25 14:06:28,584 ERROR [STDERR] (WorkerThread#39[192.168.136.172:55767]) java.lang.NullPointerException
2022-10-25 14:06:28,584 ERROR [com.orderentry.ThisClass] (WorkerThread#39[192.168.136.172:55767]) ********FAILURE END********

I cannot figure out why the information from the stack trace is so sparse. My guess is that there's a suppressed exception deep down and that just adding a call to e.getSuppressed() will ferret this out. I'm not sure. But why is the stack trace being swallowed? Maybe it's something obvious that I am missing. I'm sure we are doing some really stupid things here, but I didn't write most of this code and I am trying to un-stupid it.

0

There are 0 answers