Place a try / catch around the function the enemy hits. In the statement, you can print a stack trace and exception information.
Sort of:
try { enemyHit(); } catch (Exception e) { System.out.print("RuntimeException: "); System.out.println(e.getMessage()); e.printStackTrace(); }
Run the jar from the command line so that printouts are still present when the ATM fails. Also, write the error information to a file.
You can push try / catch further on the stack if it doesn't catch anything. If you don't catch the exceptions elsewhere, you can put this attempt in the full path at the top of your stack around your main loop.
I would not recommend keeping try / catch in your release code if you are sure that the error has been resolved. There are performance issues related to try / catch that will slow down your game if you have surrounding frequently used functions.
source share