method to print exception