Use new coredata error pattern
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -27,20 +27,6 @@ import (
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type ErrDataProtectionImpactAssessmentNotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
func (e ErrDataProtectionImpactAssessmentNotFound) Error() string {
|
||||
return fmt.Sprintf("data protection impact assessment not found: %q", e.Identifier)
|
||||
}
|
||||
|
||||
type ErrNoDataProtectionImpactAssessmentsFound struct{}
|
||||
|
||||
func (e ErrNoDataProtectionImpactAssessmentsFound) Error() string {
|
||||
return "no data protection impact assessments found"
|
||||
}
|
||||
|
||||
type (
|
||||
DataProtectionImpactAssessment struct {
|
||||
ID gid.GID `db:"id"`
|
||||
@@ -263,8 +249,9 @@ LIMIT 1;
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[DataProtectionImpactAssessment])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrDataProtectionImpactAssessmentNotFound{Identifier: dpiaID.String()}
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect data protection impact assessment: %w", err)
|
||||
}
|
||||
|
||||
@@ -314,8 +301,9 @@ LIMIT 1;
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[DataProtectionImpactAssessment])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrDataProtectionImpactAssessmentNotFound{Identifier: processingActivityID.String()}
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot collect data protection impact assessment: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,20 +27,6 @@ import (
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type ErrTransferImpactAssessmentNotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
func (e ErrTransferImpactAssessmentNotFound) Error() string {
|
||||
return fmt.Sprintf("transfer impact assessment not found: %q", e.Identifier)
|
||||
}
|
||||
|
||||
type ErrNoTransferImpactAssessmentsFound struct{}
|
||||
|
||||
func (e ErrNoTransferImpactAssessmentsFound) Error() string {
|
||||
return "no transfer impact assessments found"
|
||||
}
|
||||
|
||||
type (
|
||||
TransferImpactAssessment struct {
|
||||
ID gid.GID `db:"id"`
|
||||
@@ -262,7 +248,7 @@ LIMIT 1;
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TransferImpactAssessment])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrTransferImpactAssessmentNotFound{Identifier: tiaID.String()}
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
return fmt.Errorf("cannot collect transfer impact assessment: %w", err)
|
||||
}
|
||||
@@ -313,7 +299,7 @@ LIMIT 1;
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TransferImpactAssessment])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrTransferImpactAssessmentNotFound{Identifier: processingActivityID.String()}
|
||||
return ErrResourceNotFound
|
||||
}
|
||||
return fmt.Errorf("cannot collect transfer impact assessment: %w", err)
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ func (s *DataProtectionImpactAssessmentService) ExportPDF(
|
||||
}
|
||||
|
||||
if len(assessments) == 0 {
|
||||
return &coredata.ErrNoDataProtectionImpactAssessmentsFound{}
|
||||
return coredata.ErrResourceNotFound
|
||||
}
|
||||
|
||||
organization := &coredata.Organization{}
|
||||
|
||||
@@ -318,7 +318,7 @@ func (s *TransferImpactAssessmentService) ExportPDF(
|
||||
}
|
||||
|
||||
if len(assessments) == 0 {
|
||||
return &coredata.ErrNoTransferImpactAssessmentsFound{}
|
||||
return coredata.ErrResourceNotFound
|
||||
}
|
||||
|
||||
organization := &coredata.Organization{}
|
||||
|
||||
@@ -3801,10 +3801,10 @@ func (r *mutationResolver) ExportDataProtectionImpactAssessmentsPDF(ctx context.
|
||||
|
||||
pdf, err := prb.DataProtectionImpactAssessments.ExportPDF(ctx, input.OrganizationID, dpiaFilter)
|
||||
if err != nil {
|
||||
var errNotFound *coredata.ErrNoDataProtectionImpactAssessmentsFound
|
||||
if errors.As(err, &errNotFound) {
|
||||
return nil, gqlutils.NotFound(errNotFound)
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot export data protection impact assessments PDF: %w", err))
|
||||
}
|
||||
|
||||
@@ -3827,9 +3827,8 @@ func (r *mutationResolver) ExportTransferImpactAssessmentsPDF(ctx context.Contex
|
||||
|
||||
pdf, err := prb.TransferImpactAssessments.ExportPDF(ctx, input.OrganizationID, tiaFilter)
|
||||
if err != nil {
|
||||
var errNotFound *coredata.ErrNoTransferImpactAssessmentsFound
|
||||
if errors.As(err, &errNotFound) {
|
||||
return nil, gqlutils.NotFound(errNotFound)
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(err)
|
||||
}
|
||||
panic(fmt.Errorf("cannot export transfer impact assessments PDF: %w", err))
|
||||
}
|
||||
@@ -5847,10 +5846,10 @@ func (r *processingActivityResolver) DataProtectionImpactAssessment(ctx context.
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
var errNotFound *coredata.ErrDataProtectionImpactAssessmentNotFound
|
||||
if errors.As(err, &errNotFound) {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get processing activity dpia: %w", err))
|
||||
}
|
||||
|
||||
@@ -5865,10 +5864,10 @@ func (r *processingActivityResolver) TransferImpactAssessment(ctx context.Contex
|
||||
|
||||
tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
var errNotFound *coredata.ErrTransferImpactAssessmentNotFound
|
||||
if errors.As(err, &errNotFound) {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get processing activity tia: %w", err))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user