示例#1
0
        /// <summary>
        /// 封装返回的警告信息
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public static HttpResponseMessage WarningResponse(Exception e)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            if (e is AspodesException)
            {
                AspodesException aspodes = (AspodesException)e;
                return(new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.PreconditionFailed,
                    Content = new StringContent(aspodes.ToJsonString())
                });
            }
            return(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.PreconditionFailed,
                Content = new StringContent(e.Message)
            });
        }
示例#2
0
        /// <summary>
        /// 封装返回的异常信息
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public static HttpResponseMessage ExceptionResponse(Exception e)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            if (e is AspodesException)
            {
                AspodesException aspodes = (AspodesException)e;
                return(new HttpResponseMessage
                {
                    StatusCode = aspodes.GetHttpCode(),
                    Content = new StringContent(aspodes.ToJsonString())
                });
            }
            return(new HttpResponseMessage
            {
                StatusCode = System.Net.HttpStatusCode.InternalServerError,
                Content = new StringContent(e.Message)
            });
        }