Exception handler and logger