refactoring respondOnException.