@@ -23,33 +23,24 @@ public static async Task<T> SendRequestAsync<T>(this Task<T> asyncRequest)
23
23
}
24
24
catch ( FlurlHttpException ex )
25
25
{
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 )
32
29
{
33
- throw ;
30
+ couchError = new CouchError ( ) ;
34
31
}
35
32
36
- if ( couchError != null )
33
+ switch ( ex . Call . HttpStatus )
37
34
{
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 ) ;
51
43
}
52
- throw new CouchException ( couchError . Error , couchError . Reason ) ;
53
44
}
54
45
}
55
46
0 commit comments