Improve framework import error handling
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Simplified policy data model by removing version field and optimistic concurrency
|
- Simplified policy data model by removing version field and optimistic concurrency
|
||||||
- Refactored policy update flow to load-modify-save pattern
|
- Refactored policy update flow to load-modify-save pattern
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Added user-friendly error messages when importing frameworks that already exist
|
||||||
|
|
||||||
## [0.4.1] - 2025-04-09
|
## [0.4.1] - 2025-04-09
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package console_v1
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -459,6 +460,17 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
|
|||||||
|
|
||||||
framework, err := svc.Frameworks.Import(ctx, input.OrganizationID, req)
|
framework, err := svc.Frameworks.Import(ctx, input.OrganizationID, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var errFrameworkReferenceIDAlreadyExists *coredata.ErrFrameworkReferenceIDAlreadyExists
|
||||||
|
if errors.As(err, &errFrameworkReferenceIDAlreadyExists) {
|
||||||
|
return nil, &gqlerror.Error{
|
||||||
|
Err: err,
|
||||||
|
Message: fmt.Sprintf("framework %q already exists", req.Framework.Name),
|
||||||
|
Extensions: map[string]any{
|
||||||
|
"frameworkReferenceId": errFrameworkReferenceIDAlreadyExists.ReferenceID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("cannot import framework: %w", err)
|
return nil, fmt.Errorf("cannot import framework: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user