improve handleDebug

- now catching more exceptions
- exceptions are now cleaner to read in the debug.txt