@@ -23,33 +23,24 @@ public static async Task<T> SendRequestAsync<T>(this Task<T> asyncRequest)
2323 }
2424 catch ( FlurlHttpException ex )
2525 {
26- CouchError couchError ;
27- try
28- {
29- couchError = await ex . GetResponseJsonAsync < CouchError > ( ) . ConfigureAwait ( false ) ;
30- }
31- catch
26+ CouchError couchError = await ex . GetResponseJsonAsync < CouchError > ( ) . ConfigureAwait ( false ) ;
27+
28+ if ( couchError == null )
3229 {
33- throw ;
30+ couchError = new CouchError ( ) ;
3431 }
3532
36- if ( couchError != null )
33+ switch ( ex . Call . HttpStatus )
3734 {
38- switch ( ex . Call . HttpStatus )
39- {
40- case HttpStatusCode . Conflict :
41- throw couchError . NewCouchExteption ( typeof ( CouchConflictException ) ) ;
42- case HttpStatusCode . NotFound :
43- throw couchError . NewCouchExteption ( typeof ( CouchNotFoundException ) ) ;
44- case HttpStatusCode . BadRequest :
45- if ( couchError . Error == "no_usable_index" )
46- {
47- throw couchError . NewCouchExteption ( typeof ( CouchNoIndexException ) ) ;
48- }
49- break ;
50- }
35+ case HttpStatusCode . Conflict :
36+ throw couchError . NewCouchExteption ( typeof ( CouchConflictException ) ) ;
37+ case HttpStatusCode . NotFound :
38+ throw couchError . NewCouchExteption ( typeof ( CouchNotFoundException ) ) ;
39+ case HttpStatusCode . BadRequest when couchError . Error == "no_usable_index" :
40+ throw couchError . NewCouchExteption ( typeof ( CouchNoIndexException ) ) ;
41+ default :
42+ throw new CouchException ( couchError . Error , couchError . Reason ) ;
5143 }
52- throw new CouchException ( couchError . Error , couchError . Reason ) ;
5344 }
5445 }
5546
0 commit comments