diff --git a/api/actions.go b/api/actions.go index cf80a8d..95c7129 100644 --- a/api/actions.go +++ b/api/actions.go @@ -832,7 +832,7 @@ func (n *Actions) Delete(viewName, actionName string) error { } } if actionID == "" { - return fmt.Errorf("unable to find action") + return ActionNotFound(actionID) } var mutation struct { diff --git a/api/error.go b/api/error.go index a33c2ba..7432abb 100644 --- a/api/error.go +++ b/api/error.go @@ -7,6 +7,7 @@ import ( type EntityType string const ( + EntityTypeIngestToken EntityType = "ingest-token" EntityTypeParser EntityType = "parser" EntityTypeAction EntityType = "action" EntityTypeAlert EntityType = "alert" @@ -36,6 +37,13 @@ func (e EntityNotFound) Error() string { return fmt.Sprintf("%s %q not found", e.entityType.String(), e.key) } +func IngestTokenNotFound(name string) error { + return EntityNotFound{ + entityType: EntityTypeIngestToken, + key: name, + } +} + func ParserNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeParser, diff --git a/api/ingest-tokens.go b/api/ingest-tokens.go index 470db50..28da72a 100644 --- a/api/ingest-tokens.go +++ b/api/ingest-tokens.go @@ -1,7 +1,6 @@ package api import ( - "fmt" graphql "github.com/cli/shurcooL-graphql" ) @@ -61,7 +60,7 @@ func (i *IngestTokens) Get(repoName, tokenName string) (*IngestToken, error) { } } - return nil, fmt.Errorf("could not find an ingest token with name '%s' in repo '%s'", tokenName, repoName) + return nil, IngestTokenNotFound(tokenName) } func toIngestToken(data ingestTokenData) *IngestToken {