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"
|
"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 (
|
type (
|
||||||
DataProtectionImpactAssessment struct {
|
DataProtectionImpactAssessment struct {
|
||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
@@ -263,8 +249,9 @@ LIMIT 1;
|
|||||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[DataProtectionImpactAssessment])
|
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[DataProtectionImpactAssessment])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
return &ErrDataProtectionImpactAssessmentNotFound{Identifier: dpiaID.String()}
|
return ErrResourceNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("cannot collect data protection impact assessment: %w", err)
|
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])
|
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[DataProtectionImpactAssessment])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
return &ErrDataProtectionImpactAssessmentNotFound{Identifier: processingActivityID.String()}
|
return ErrResourceNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("cannot collect data protection impact assessment: %w", err)
|
return fmt.Errorf("cannot collect data protection impact assessment: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,20 +27,6 @@ import (
|
|||||||
"go.probo.inc/probo/pkg/page"
|
"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 (
|
type (
|
||||||
TransferImpactAssessment struct {
|
TransferImpactAssessment struct {
|
||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
@@ -262,7 +248,7 @@ LIMIT 1;
|
|||||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TransferImpactAssessment])
|
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TransferImpactAssessment])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
return &ErrTransferImpactAssessmentNotFound{Identifier: tiaID.String()}
|
return ErrResourceNotFound
|
||||||
}
|
}
|
||||||
return fmt.Errorf("cannot collect transfer impact assessment: %w", err)
|
return fmt.Errorf("cannot collect transfer impact assessment: %w", err)
|
||||||
}
|
}
|
||||||
@@ -313,7 +299,7 @@ LIMIT 1;
|
|||||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TransferImpactAssessment])
|
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[TransferImpactAssessment])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
return &ErrTransferImpactAssessmentNotFound{Identifier: processingActivityID.String()}
|
return ErrResourceNotFound
|
||||||
}
|
}
|
||||||
return fmt.Errorf("cannot collect transfer impact assessment: %w", err)
|
return fmt.Errorf("cannot collect transfer impact assessment: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ func (s *DataProtectionImpactAssessmentService) ExportPDF(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(assessments) == 0 {
|
if len(assessments) == 0 {
|
||||||
return &coredata.ErrNoDataProtectionImpactAssessmentsFound{}
|
return coredata.ErrResourceNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
organization := &coredata.Organization{}
|
organization := &coredata.Organization{}
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ func (s *TransferImpactAssessmentService) ExportPDF(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(assessments) == 0 {
|
if len(assessments) == 0 {
|
||||||
return &coredata.ErrNoTransferImpactAssessmentsFound{}
|
return coredata.ErrResourceNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
organization := &coredata.Organization{}
|
organization := &coredata.Organization{}
|
||||||
|
|||||||
@@ -3801,10 +3801,10 @@ func (r *mutationResolver) ExportDataProtectionImpactAssessmentsPDF(ctx context.
|
|||||||
|
|
||||||
pdf, err := prb.DataProtectionImpactAssessments.ExportPDF(ctx, input.OrganizationID, dpiaFilter)
|
pdf, err := prb.DataProtectionImpactAssessments.ExportPDF(ctx, input.OrganizationID, dpiaFilter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var errNotFound *coredata.ErrNoDataProtectionImpactAssessmentsFound
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||||
if errors.As(err, &errNotFound) {
|
return nil, gqlutils.NotFound(err)
|
||||||
return nil, gqlutils.NotFound(errNotFound)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot export data protection impact assessments PDF: %w", 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)
|
pdf, err := prb.TransferImpactAssessments.ExportPDF(ctx, input.OrganizationID, tiaFilter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var errNotFound *coredata.ErrNoTransferImpactAssessmentsFound
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||||
if errors.As(err, &errNotFound) {
|
return nil, gqlutils.NotFound(err)
|
||||||
return nil, gqlutils.NotFound(errNotFound)
|
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("cannot export transfer impact assessments PDF: %w", 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)
|
dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var errNotFound *coredata.ErrDataProtectionImpactAssessmentNotFound
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||||
if errors.As(err, &errNotFound) {
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get processing activity dpia: %w", err))
|
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)
|
tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var errNotFound *coredata.ErrTransferImpactAssessmentNotFound
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||||
if errors.As(err, &errNotFound) {
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get processing activity tia: %w", err))
|
panic(fmt.Errorf("cannot get processing activity tia: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user