Finally got the trace method to handle the exception properly with some help