File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
smart-client-core/src/main/java/com/emc/rest/smart
smart-client-jersey/src/main/java/com/emc/rest/smart/jersey Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1+ package com .emc .rest .smart ;
2+
3+ public class SmartClientException extends RuntimeException {
4+
5+ private ErrorType errorType = ErrorType .Unknown ;
6+
7+ public SmartClientException (String message ) {
8+ super (message );
9+ }
10+
11+ public SmartClientException (String message , Throwable cause ) {
12+ super (message , cause );
13+ }
14+ public ErrorType getErrorType () {
15+ return errorType ;
16+ }
17+
18+ public void setErrorType (ErrorType errorType ) {
19+ this .errorType = errorType ;
20+ }
21+
22+ public boolean isServerError () {
23+ return this .getErrorType ().equals (SmartClientException .ErrorType .Service );
24+ }
25+
26+ public enum ErrorType {
27+ Client , // 4xx
28+ Service , // 5xx
29+ Unknown
30+ }
31+
32+ }
Original file line number Diff line number Diff line change 1616package com .emc .rest .smart .jersey ;
1717
1818import com .emc .rest .smart .Host ;
19+ import com .emc .rest .smart .SmartClientException ;
1920import com .emc .rest .smart .SmartConfig ;
2021import com .sun .jersey .api .client .ClientHandlerException ;
2122import com .sun .jersey .api .client .ClientRequest ;
@@ -74,9 +75,9 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio
7475
7576 return response ;
7677 } catch (RuntimeException e ) {
77-
7878 // capture requests stats (error)
79- host .callComplete (true );
79+ boolean isServerError = e instanceof SmartClientException && ((SmartClientException ) e ).isServerError ();
80+ host .callComplete (isServerError );
8081 host .connectionClosed ();
8182
8283 throw e ;
You can’t perform that action at this time.
0 commit comments