Skip to content

Commit

Permalink
revert: revert the error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Nov 22, 2024
1 parent a99a19c commit 433c878
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/api/api_default_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,25 +796,25 @@ 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 {
err := common.RequestError{
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{
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 433c878

Please sign in to comment.