From 433c878d3ed3053d89de7f249ec5bf47a3451cb8 Mon Sep 17 00:00:00 2001 From: Mengling Ding Date: Fri, 22 Nov 2024 10:32:38 -0600 Subject: [PATCH] revert: revert the error handling --- pkg/api/api_default_service.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/api/api_default_service.go b/pkg/api/api_default_service.go index 7b66760..c458c40 100644 --- a/pkg/api/api_default_service.go +++ b/pkg/api/api_default_service.go @@ -796,7 +796,7 @@ func (cfm *CfmApiService) BladesPost(ctx context.Context, applianceId string, cr appliance, err := manager.GetApplianceById(ctx, applianceId) if err != nil { - return openapi.Response(http.StatusBadRequest, nil), err + return formatErrorResp(ctx, err.(*common.RequestError)) } if len(appliance.Blades) == MAX_COUNT_BLADES { @@ -804,17 +804,17 @@ func (cfm *CfmApiService) BladesPost(ctx context.Context, applianceId string, cr StatusCode: common.StatusBladesExceedMaximum, Err: fmt.Errorf("cfm-service at maximum blade capacity (%d) for this appliance (%s)", MAX_COUNT_BLADES, applianceId), } - return openapi.Response(http.StatusBadRequest, nil), &err + return formatErrorResp(ctx, &err) } blade, err := appliance.AddBlade(ctx, &credentials) if err != nil { - return openapi.Response(http.StatusBadRequest, nil), err + return formatErrorResp(ctx, err.(*common.RequestError)) } totals, err := blade.GetResourceTotals(ctx) if err != nil { - return openapi.Response(http.StatusBadRequest, nil), err + return formatErrorResp(ctx, err.(*common.RequestError)) } b := openapi.Blade{ @@ -1218,12 +1218,12 @@ func (cfm *CfmApiService) HostsPost(ctx context.Context, credentials openapi.Cre StatusCode: common.StatusHostsExceedMaximum, Err: fmt.Errorf("cfm-service at maximum host capacity (%d)", MAX_COUNT_HOSTS), } - return openapi.Response(http.StatusBadRequest, nil), &err + return formatErrorResp(ctx, &err) } host, err := manager.AddHost(ctx, &credentials) if err != nil { - return openapi.Response(http.StatusBadRequest, nil), err + return formatErrorResp(ctx, err.(*common.RequestError)) } h := openapi.Host{