Beispiel #1
0
        private void HandleLastError(Action nextStep)
        {
            string path = FileErrorPath();

            if (File.Exists(path))
            {
                using (FileStream stream = new FileStream(path, FileMode.Open)) {
                    object report = null;

                    XmlSerializer serializer = new XmlSerializer(typeof(Log));
                    try {
                        report = serializer.Deserialize(stream);
                    } catch (XmlException) {
                        stream.Position = 0;
                        using (StreamReader reader = new StreamReader(stream))
                            report = reader.ReadToEnd();
                    }

                    _exceptionHandler.Handle(report, nextStep);
                }
            }
            else
            {
                nextStep();
            }
        }
Beispiel #2
0
        private void HandleLastError(Action nextStep)
        {
            string path = FileErrorPath();

            if (File.Exists(path))
            {
                using (var stream = new FileStream(path, FileMode.Open))
                {
                    IReport report = LogManager.Reporter.CreateReport(stream);
                    _exceptionHandler.Handle(report, nextStep);
                }
            }
            else
            {
                nextStep();
            }
        }
    public void ShouldHandleException()
    {
        //Arrange
        var sut           = new CustomExceptionHandler();
        var exception     = new Exception("Hello World");
        var catchblock    = new ExceptionContextCatchBlock("webpi", true, false);
        var configuration = new HttpConfiguration();
        var request       = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/test");

        request.SetConfiguration(configuration);
        var exceptionContext = new ExceptionContext(exception, catchblock, request);
        var context          = new ExceptionHandlerContext(exceptionContext);

        Assert.IsNull(context.Result);
        //Act
        sut.Handle(context);
        //Assert
        Assert.IsNotNull(context.Result);
    }
Beispiel #4
0
 public void HandleException(Exception e)
 {
     _exceptionHandler.Handle(e);
 }