@ali qq duoshao hao jiao liu
when I visit below
[Authenticate]
[Route("/h2")]
[Route("/h2/{Name}")]
public class H2 : IReturn<HelloResponse>
{
public string Name { get; set; }
}
{“ResponseStatus”:{“ErrorCode”:“NullReferenceException”,“Message”:“未将对象引用设置到对象的实例。”,“StackTrace”:" 在 ServiceStack.HttpRequestExtensions.ToErrorCode(Exception ex)\r\n 在 ServiceStack.HttpResponseExtensionsInternal.ToErrorResponse(Exception ex)\r\n 在 ServiceStack.HttpResponseExtensionsInternal.WriteErrorToResponse(IResponse httpRes, IRequest httpReq, String contentType, String operationName, String errorMessage, Exception ex, Int32 statusCode)\r\n 在 ServiceStack.HttpResponseExtensionsInternal.WriteError(IResponse httpRes, IRequest httpReq, Object dto, String errorMessage)\r\n 在 ServiceStack.AuthenticateAttribute.Execute(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.RequestFilterAttribute.RequestFilter(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.ServiceStackHost.ApplyRequestFiltersSingle(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.ServiceStackHost.ApplyRequestFilters(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)"}}
public static string ToErrorCode(this Exception ex) // ex is null so ex.GetType() error
{
var hasErrorCode = ex as IHasErrorCode;
return (hasErrorCode != null ? hasErrorCode.ErrorCode : null)
?? ex.GetType().Name;
}