File tree Expand file tree Collapse file tree 6 files changed +9
-30
lines changed
Attributes/FilterAttributes Expand file tree Collapse file tree 6 files changed +9
-30
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ public override Task OnBeginRequestAsync(ApiActionContext context)
3232 /// <returns></returns>
3333 public override async Task OnEndRequestAsync ( ApiActionContext context )
3434 {
35+ if ( context . Exception != null )
36+ {
37+ return ;
38+ }
39+
3540 var request = context . RequestMessage ;
3641 var dateTime = DateTime . Now . ToString ( "HH:mm:ss.fff" ) ;
3742 var timeSpan = DateTime . Now . Subtract ( context . Tags [ "BeginTime" ] . As < DateTime > ( ) ) ;
Original file line number Diff line number Diff line change @@ -38,23 +38,12 @@ public virtual Task OnBeginRequestAsync(ApiActionContext context)
3838
3939 /// <summary>
4040 /// 请求完成之后
41- ///
4241 /// </summary>
4342 /// <param name="context">上下文</param>
4443 /// <returns></returns>
4544 public virtual Task OnEndRequestAsync ( ApiActionContext context )
4645 {
4746 return ApiTask . CompletedTask ;
4847 }
49-
50- /// <summary>
51- /// 执行请求异常时
52- /// </summary>
53- /// <param name="context">上下文</param>
54- /// <returns></returns>
55- public virtual Task OnRequestExceptionAsync ( ApiActionContext context )
56- {
57- return ApiTask . CompletedTask ;
58- }
5948 }
6049}
Original file line number Diff line number Diff line change @@ -84,16 +84,6 @@ Task IApiActionFilter.OnEndRequestAsync(ApiActionContext context)
8484 return ApiTask . CompletedTask ;
8585 }
8686
87- /// <summary>
88- /// 执行请求异常时
89- /// </summary>
90- /// <param name="context">上下文</param>
91- /// <returns></returns>
92- Task IApiActionFilter . OnRequestExceptionAsync ( ApiActionContext context )
93- {
94- return ApiTask . CompletedTask ;
95- }
96-
9787 /// <summary>
9888 /// 准备请求之前
9989 /// </summary>
Original file line number Diff line number Diff line change @@ -98,8 +98,6 @@ internal async Task ExecRequestAsync()
9898 catch ( Exception ex )
9999 {
100100 this . Exception = ex ;
101- await this . ExecFiltersAsync ( filter => filter . OnRequestExceptionAsync ) ;
102- throw ex ;
103101 }
104102 }
105103
Original file line number Diff line number Diff line change @@ -22,12 +22,5 @@ public interface IApiActionFilter
2222 /// <param name="context">上下文</param>
2323 /// <returns></returns>
2424 Task OnEndRequestAsync ( ApiActionContext context ) ;
25-
26- /// <summary>
27- /// 执行请求异常时
28- /// </summary>
29- /// <param name="context">上下文</param>
30- /// <returns></returns>
31- Task OnRequestExceptionAsync ( ApiActionContext context ) ;
3225 }
3326}
Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ private async Task<TResult> RequestAsync()
134134 await context . ExecRequestAsync ( ) ;
135135 await context . ExecFiltersAsync ( filter => filter . OnEndRequestAsync ) ;
136136
137+ if ( context . Exception != null )
138+ {
139+ throw context . Exception ;
140+ }
137141 return ( TResult ) context . Result ;
138142 }
139143 }
You can’t perform that action at this time.
0 commit comments