File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
src/Cnblogs.Architecture.Ddd.Cqrs.ServiceAgent Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -131,19 +131,13 @@ public async Task<CommandResponse<TResponse, ServiceAgentError>> PutCommandAsync
131
131
/// <returns>The query result, can be null if item does not exists or status code is 404.</returns>
132
132
public async Task < T ? > GetItemAsync < T > ( string url )
133
133
{
134
- try
134
+ var response = await HttpClient . GetAsync ( url ) ;
135
+ return response . StatusCode switch
135
136
{
136
- return await HttpClient . GetFromJsonAsync < T > ( url ) ;
137
- }
138
- catch ( HttpRequestException e )
139
- {
140
- if ( e . StatusCode == HttpStatusCode . NotFound )
141
- {
142
- return default ;
143
- }
144
-
145
- throw ;
146
- }
137
+ HttpStatusCode . OK => await response . Content . ReadFromJsonAsync < T > ( ) ,
138
+ HttpStatusCode . NotFound => default ,
139
+ _ => default
140
+ } ;
147
141
}
148
142
149
143
/// <summary>
You can’t perform that action at this time.
0 commit comments