catch all exceptions unless debug mode is true