Added trace output to exception handling