view Implab/ExceptionHelpers.cs @ 264:3a6e18c432be v3

Added XmlToJson xsl transformation. Added JsonXmlReader.CreateJsonXmlReader(...) methods Added SerializationHelpers.SerializeJson/DeserializeJson methods
author cin
date Mon, 16 Apr 2018 18:43:49 +0300
parents d82909310094
children
line wrap: on
line source

using System;
using System.Reflection;
using System.Runtime.ExceptionServices;

namespace Implab {
    static class ExceptionHelpers {
        public static Exception Rethrow(this Exception that) {
            ExceptionDispatchInfo.Capture(that).Throw();
            return new TargetInvocationException(that);
        }

        public static Exception Wrap(this Exception that) {
            if (that == null)
                return new Exception();
            else if (that is OperationCanceledException)
                return new OperationCanceledException("The operation has been cancelled", that);
            else
                return new TargetInvocationException(that);
        }
    }
}