Skip to content

Commit

Permalink
🐛 return proper error when no provider could be detected (#3138)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock authored Jan 29, 2024
1 parent cfb0a75 commit e161f1e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ func ListAll() ([]*Provider, error) {
return res, nil
}

type ProviderNotFoundError struct {
lookup ProviderLookup
}

func (e *ProviderNotFoundError) Error() string {
return "cannot find provider for " + e.lookup.String()
}

// EnsureProvider makes sure that a given provider exists and returns it.
// You can supply providers either via:
// 1. providerID, which universally identifies it, e.g. "go.mondoo.com/cnquery/v10/providers/os"
Expand Down Expand Up @@ -319,7 +327,7 @@ func EnsureProvider(search ProviderLookup, autoUpdate bool, existing Providers)
if upstream == nil {
// we can't find any provider for this connector in our default set
// FIXME: This causes a panic in the CLI, we should handle this better
return nil, nil
return nil, &ProviderNotFoundError{lookup: search}
}

if !autoUpdate {
Expand Down

0 comments on commit e161f1e

Please sign in to comment.