Skip to content

Commit

Permalink
Add custom scan error type
Browse files Browse the repository at this point in the history
  • Loading branch information
ccampo133 committed Feb 9, 2024
1 parent d4b7f84 commit e67c67e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions aws/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aws

import (
"context"
"errors"
"fmt"
"sync"

Expand Down Expand Up @@ -87,7 +86,7 @@ func (s *AWSScanner) Scan(ctx context.Context) (*scan.ScanResults, error) {
Repositories: repositories,
}

return scanResults, errors.Join(scanErrors...)
return scanResults, &scan.ScanError{Errs: scanErrors}
}

func scanRegion(
Expand Down
15 changes: 15 additions & 0 deletions scan/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scan

import (
"context"
"errors"
"time"
)

Expand Down Expand Up @@ -39,3 +40,17 @@ type Repository struct {
type ScanResults struct {
Repositories []Repository
}

// ScanError is an error type that represents a collection of errors that
// occurred during the scanning process.
type ScanError struct {
Errs []error
}

func (e *ScanError) Error() string {
return errors.Join(e.Errs...).Error()
}

func (e *ScanError) Unwrap() []error {
return e.Errs
}

0 comments on commit e67c67e

Please sign in to comment.