@@ -437,7 +437,7 @@ func (h *Handler) handlePostIndex(w http.ResponseWriter, r *http.Request) {
437
437
}
438
438
439
439
_ , err = h .API .CreateIndex (r .Context (), indexName , req .Options )
440
- if err == ErrIndexExists {
440
+ if errors . Cause ( err ) == ErrIndexExists {
441
441
http .Error (w , err .Error (), http .StatusConflict )
442
442
return
443
443
} else if err != nil {
@@ -464,7 +464,7 @@ func (h *Handler) handlePostIndexAttrDiff(w http.ResponseWriter, r *http.Request
464
464
465
465
attrs , err := h .API .IndexAttrDiff (r .Context (), indexName , req .Blocks )
466
466
if err != nil {
467
- if err == ErrIndexNotFound {
467
+ if errors . Cause ( err ) == ErrIndexNotFound {
468
468
http .Error (w , err .Error (), http .StatusNotFound )
469
469
} else {
470
470
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -505,7 +505,7 @@ func (h *Handler) handlePostFrame(w http.ResponseWriter, r *http.Request) {
505
505
}
506
506
_ , err = h .API .CreateFrame (r .Context (), indexName , frameName , req .Options )
507
507
if err != nil {
508
- switch err {
508
+ switch errors . Cause ( err ) {
509
509
case ErrIndexNotFound :
510
510
http .Error (w , err .Error (), http .StatusNotFound )
511
511
case ErrFrameExists :
@@ -573,7 +573,7 @@ func (h *Handler) handleDeleteFrame(w http.ResponseWriter, r *http.Request) {
573
573
574
574
err := h .API .DeleteFrame (r .Context (), indexName , frameName )
575
575
if err != nil {
576
- if err == ErrIndexNotFound {
576
+ if errors . Cause ( err ) == ErrIndexNotFound {
577
577
if err := json .NewEncoder (w ).Encode (deleteIndexResponse {}); err != nil {
578
578
h .Logger .Printf ("response encoding error: %s" , err )
579
579
}
@@ -612,7 +612,7 @@ func (h *Handler) handlePostFrameField(w http.ResponseWriter, r *http.Request) {
612
612
}
613
613
614
614
if err := h .API .CreateField (r .Context (), indexName , frameName , field ); err != nil {
615
- if err == ErrFrameNotFound {
615
+ if errors . Cause ( err ) == ErrFrameNotFound {
616
616
http .Error (w , err .Error (), http .StatusNotFound )
617
617
} else {
618
618
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -641,7 +641,7 @@ func (h *Handler) handleDeleteFrameField(w http.ResponseWriter, r *http.Request)
641
641
fieldName := mux .Vars (r )["field" ]
642
642
643
643
if err := h .API .DeleteField (r .Context (), indexName , frameName , fieldName ); err != nil {
644
- if err == ErrFrameNotFound {
644
+ if errors . Cause ( err ) == ErrFrameNotFound {
645
645
http .Error (w , err .Error (), http .StatusNotFound )
646
646
} else {
647
647
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -661,7 +661,7 @@ func (h *Handler) handleGetFrameFields(w http.ResponseWriter, r *http.Request) {
661
661
662
662
fields , err := h .API .Fields (r .Context (), indexName , frameName )
663
663
if err != nil {
664
- switch err {
664
+ switch errors . Cause ( err ) {
665
665
case ErrIndexNotFound :
666
666
fallthrough
667
667
case ErrFrameNotFound :
@@ -691,7 +691,7 @@ func (h *Handler) handleGetFrameViews(w http.ResponseWriter, r *http.Request) {
691
691
692
692
views , err := h .API .Views (r .Context (), indexName , frameName )
693
693
if err != nil {
694
- if err == ErrFrameNotFound {
694
+ if errors . Cause ( err ) == ErrFrameNotFound {
695
695
http .Error (w , err .Error (), http .StatusNotFound )
696
696
} else {
697
697
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -717,7 +717,7 @@ func (h *Handler) handleDeleteView(w http.ResponseWriter, r *http.Request) {
717
717
viewName := mux .Vars (r )["view" ]
718
718
719
719
if err := h .API .DeleteView (r .Context (), indexName , frameName , viewName ); err != nil {
720
- if err == ErrFrameNotFound {
720
+ if errors . Cause ( err ) == ErrFrameNotFound {
721
721
http .Error (w , err .Error (), http .StatusNotFound )
722
722
} else {
723
723
http .Error (w , err .Error (), http .StatusBadRequest )
@@ -751,7 +751,7 @@ func (h *Handler) handlePostFrameAttrDiff(w http.ResponseWriter, r *http.Request
751
751
752
752
attrs , err := h .API .FrameAttrDiff (r .Context (), indexName , frameName , req .Blocks )
753
753
if err != nil {
754
- switch err {
754
+ switch errors . Cause ( err ) {
755
755
case ErrFragmentNotFound :
756
756
http .Error (w , err .Error (), http .StatusNotFound )
757
757
default :
@@ -878,7 +878,7 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) {
878
878
}
879
879
880
880
if err := h .API .Import (r .Context (), req ); err != nil {
881
- switch err {
881
+ switch errors . Cause ( err ) {
882
882
case ErrIndexNotFound :
883
883
fallthrough
884
884
case ErrFrameNotFound :
@@ -931,7 +931,7 @@ func (h *Handler) handlePostImportValue(w http.ResponseWriter, r *http.Request)
931
931
}
932
932
933
933
if err = h .API .ImportValue (r .Context (), req ); err != nil {
934
- switch err {
934
+ switch errors . Cause ( err ) {
935
935
case ErrIndexNotFound :
936
936
fallthrough
937
937
case ErrFrameNotFound :
@@ -980,7 +980,7 @@ func (h *Handler) handleGetExportCSV(w http.ResponseWriter, r *http.Request) {
980
980
}
981
981
982
982
if err = h .API .ExportCSV (r .Context (), index , frame , view , slice , w ); err != nil {
983
- switch err {
983
+ switch errors . Cause ( err ) {
984
984
case ErrFragmentNotFound :
985
985
break
986
986
case ErrClusterDoesNotOwnSlice :
@@ -1051,7 +1051,7 @@ func (h *Handler) handlePostFragmentData(w http.ResponseWriter, r *http.Request)
1051
1051
}
1052
1052
1053
1053
if err = h .API .UnmarshalFragment (r .Context (), q .Get ("index" ), q .Get ("frame" ), q .Get ("view" ), slice , r .Body ); err != nil {
1054
- if err == ErrFrameNotFound {
1054
+ if errors . Cause ( err ) == ErrFrameNotFound {
1055
1055
http .Error (w , ErrFrameNotFound .Error (), http .StatusNotFound )
1056
1056
} else {
1057
1057
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -1065,7 +1065,7 @@ func (h *Handler) handleGetFragmentBlockData(w http.ResponseWriter, r *http.Requ
1065
1065
if err != nil {
1066
1066
if _ , ok := err .(BadRequestError ); ok {
1067
1067
http .Error (w , err .Error (), http .StatusBadRequest )
1068
- } else if err == ErrFragmentNotFound {
1068
+ } else if errors . Cause ( err ) == ErrFragmentNotFound {
1069
1069
http .Error (w , err .Error (), http .StatusNotFound )
1070
1070
} else {
1071
1071
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -1091,7 +1091,7 @@ func (h *Handler) handleGetFragmentBlocks(w http.ResponseWriter, r *http.Request
1091
1091
1092
1092
blocks , err := h .API .FragmentBlocks (r .Context (), q .Get ("index" ), q .Get ("frame" ), q .Get ("view" ), slice )
1093
1093
if err != nil {
1094
- if err == ErrFragmentNotFound {
1094
+ if errors . Cause ( err ) == ErrFragmentNotFound {
1095
1095
http .Error (w , err .Error (), http .StatusNotFound )
1096
1096
} else {
1097
1097
http .Error (w , err .Error (), http .StatusInternalServerError )
@@ -1131,7 +1131,7 @@ func (h *Handler) handlePostFrameRestore(w http.ResponseWriter, r *http.Request)
1131
1131
}
1132
1132
1133
1133
err = h .API .RestoreFrame (r .Context (), indexName , frameName , host )
1134
- switch err {
1134
+ switch errors . Cause ( err ) {
1135
1135
case nil :
1136
1136
break
1137
1137
case ErrFrameNotFound :
0 commit comments