@@ -22,11 +22,16 @@ import (
2222)
2323
2424func getHandlerErrorCode (response * http.Response ) string {
25+ if response == nil {
26+ return string (types .HandlerErrorCodeInternalFailure )
27+ }
2528 switch response .StatusCode {
2629 case http .StatusBadRequest :
2730 return string (types .HandlerErrorCodeInvalidRequest )
2831 case http .StatusNotFound :
2932 return string (types .HandlerErrorCodeNotFound )
33+ case http .StatusConflict :
34+ return string (types .HandlerErrorCodeAlreadyExists )
3035 case http .StatusInternalServerError :
3136 return string (types .HandlerErrorCodeServiceInternalError )
3237 case http .StatusPaymentRequired , http .StatusUnauthorized :
@@ -37,34 +42,6 @@ func getHandlerErrorCode(response *http.Response) string {
3742}
3843
3944func GetFailedEventByResponse (message string , response * http.Response ) handler.ProgressEvent {
40- if response == nil {
41- return handler.ProgressEvent {
42- OperationStatus : handler .Failed ,
43- Message : message ,
44- HandlerErrorCode : string (types .HandlerErrorCodeHandlerInternalFailure )}
45- }
46-
47- if response .StatusCode == http .StatusConflict {
48- return handler.ProgressEvent {
49- OperationStatus : handler .Failed ,
50- Message : message ,
51- HandlerErrorCode : string (types .HandlerErrorCodeAlreadyExists )}
52- }
53-
54- if response .StatusCode == http .StatusUnauthorized {
55- return handler.ProgressEvent {
56- OperationStatus : handler .Failed ,
57- Message : "Not found" ,
58- HandlerErrorCode : string (types .HandlerErrorCodeNotFound )}
59- }
60-
61- if response .StatusCode == http .StatusBadRequest {
62- return handler.ProgressEvent {
63- OperationStatus : handler .Failed ,
64- Message : message ,
65- HandlerErrorCode : string (types .HandlerErrorCodeNotFound )}
66- }
67-
6845 return handler.ProgressEvent {
6946 OperationStatus : handler .Failed ,
7047 Message : message ,
0 commit comments