public void ExceptionShouldBeWrittenToHeader() { const string error = "oh my, an exception!"; _controller = TestControllerBuilder.TestController().Build(); var context = new ExceptionContext { Exception = new Exception(error) }; _controller.ThrowException(context); _controller.Headers.Get(Constants.Headers.ErrorMessage).ShouldEqual(error); }
public void ExceptionShouldBeWrittenToHeaderIfRealExceptionsAreTurnedOff() { const string realError = "real error"; const string shownError = "shown error"; _controller = TestControllerBuilder.TestController().Build(); RestCore.Configuration = new Configuration {HideRealException = true, DefaultExceptionText = shownError}; var context = new ExceptionContext { Exception = new Exception(realError) }; _controller.ThrowException(context); _controller.Headers.Get(Constants.Headers.ErrorMessage).ShouldEqual(shownError); }
public void UnknownServerErrorCodeShouldBeWrittenToHeaderIfSet() { const int unknownServerErrorCode = 14; _controller = TestControllerBuilder.TestController().Build(); RestCore.Configuration = new Configuration { UnknownServerErrorCode = unknownServerErrorCode }; var context = new ExceptionContext { Exception = new Exception("error") }; _controller.ThrowException(context); _controller.Headers.Get(Constants.Headers.ErrorCode).ShouldEqual(unknownServerErrorCode.ToString()); }