public static CustomHttpException GetHttpErrorFromEx(Exception ex)
        {
            var defaultError = new CustomHttpException();

            if (ex is CustomHttpException)
            {
                defaultError = ex as CustomHttpException;
            }

            if (!(ex is CustomHttpException) && ex.InnerException != null)
            {
                defaultError = GetHttpErrorFromEx(ex.InnerException);
            }

            return(defaultError);
        }