| | |
| | | |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Web; |
| | | using System.Web.Mvc; |
| | | |
| | | |
| | | using System.Web.Http.Filters; |
| | | using System.Net.Http; |
| | | using System.Web.Http.ExceptionHandling; |
| | |
| | | namespace IStation.WebApi |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | public class CustomHandleErrorAttribute : ExceptionFilterAttribute |
| | | { |
| | |
| | | IStation.Dto.ApiResult result = null; |
| | | if (actionExecutedContext.Exception is NotImplementedException) |
| | | { |
| | | IStation.LogHelper.WriteError("NotImplementedException," + actionExecutedContext.Exception.Message); |
| | | IStation.LogHelper.Error("NotImplementedException," + actionExecutedContext.Exception.Message); |
| | | result = new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Error, actionExecutedContext.Exception.Message); |
| | | } |
| | | else if (actionExecutedContext.Exception is TimeoutException) |
| | | { |
| | | IStation.LogHelper.WriteError("TimeoutException," + actionExecutedContext.Exception.Message); |
| | | IStation.LogHelper.Error("TimeoutException," + actionExecutedContext.Exception.Message); |
| | | result = new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.TimeOut, actionExecutedContext.Exception.Message); |
| | | } |
| | | |
| | | else |
| | | { |
| | | IStation.LogHelper.WriteError( |
| | | IStation.LogHelper.Error( |
| | | string.Format("UnknowException,Exception:{0},StackTrace:{1}", |
| | | actionExecutedContext.Exception.Message, |
| | | actionExecutedContext.Exception.StackTrace)); |