Skip to content

Commit

Permalink
Reorganize error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MDrakos committed Nov 18, 2024
1 parent 7d88e59 commit 8321e42
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 308 deletions.
6 changes: 1 addition & 5 deletions pkg/platform/api/buildplanner/request/buildexpression.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ query ($commitID: ID!) {
atTime
expr
}
... on Error{
__typename
message
}
... on NotFound {
... on Error {
__typename
message
}
Expand Down
32 changes: 11 additions & 21 deletions pkg/platform/api/buildplanner/request/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,28 @@ query ($commitID: String!, $organization: String!, $project: String!, $target: S
name
namespace
version_requirements: versionRequirements {
comparator
comparator
version
}
}
resolvedSource
}
}
... on Error {
__typename
message
}
... on PlanningError {
message
... on ErrorWithSubErrors {
__typename
subErrors {
__typename
buildExprPath
... on RemediableError {
possibleRemediations {
description
suggestedPriority
}
}
... on GenericSolveError {
path
message
Expand All @@ -185,23 +193,12 @@ query ($commitID: String!, $organization: String!, $project: String!, $target: S
parameters
}
}
... on TargetNotFound {
message
requestedTarget
possibleTargets
}
}
}
}
}
... on Error {
message
}
... on NotFound {
__typename
type
resource
mayNeedAuthentication
message
}
}
Expand All @@ -210,13 +207,6 @@ query ($commitID: String!, $organization: String!, $project: String!, $target: S
__typename
message
}
... on NotFound {
__typename
type
resource
mayNeedAuthentication
message
}
}
}
`
Expand Down
85 changes: 54 additions & 31 deletions pkg/platform/api/buildplanner/request/createproject.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,60 @@ type createProject struct {
func (c *createProject) Query() string {
return `
mutation ($organization: String!, $project: String!, $private: Boolean!, $expr: BuildExpr!, $description: String!) {
createProject(input:{organization:$organization, project:$project, private:$private, expr:$expr, description:$description}) {
... on ProjectCreated {
__typename
commit {
__typename
commitId
}
}
... on AlreadyExists {
__typename
message
}
... on NotFound {
__typename
message
}
... on ParseError {
__typename
message
path
}
... on ValidationError {
__typename
message
}
... on Forbidden {
__typename
message
}
}
}`
createProject(
input: {organization: $organization, project: $project, private: $private, expr: $expr, description: $description}
) {
... on ProjectCreated {
__typename
commit {
__typename
commitId
}
}
... on Error {
__typename
message
}
... on ErrorWithSubErrors {
__typename
subErrors {
__typename
buildExprPath
... on RemediableError {
possibleRemediations {
description
suggestedPriority
}
}
... on GenericSolveError {
path
message
isTransient
validationErrors {
error
jsonPath
}
}
... on RemediableSolveError {
path
message
isTransient
errorType
validationErrors {
error
jsonPath
}
suggestedRemediations {
remediationType
command
parameters
}
}
}
}
}
}
`
}

func (c *createProject) Vars() (map[string]interface{}, error) {
Expand Down
30 changes: 15 additions & 15 deletions pkg/platform/api/buildplanner/request/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ mutation ($organization: String!, $project: String!, $commitId: String!, $target
__typename
status
}
... on PlanningError {
... on Error {
__typename
message
}
... on ErrorWithSubErrors {
__typename
subErrors {
__typename
buildExprPath
... on RemediableError {
possibleRemediations {
description
suggestedPriority
}
}
... on GenericSolveError {
buildExprPath
path
message
isTransient
validationErrors {
Expand All @@ -38,7 +48,7 @@ mutation ($organization: String!, $project: String!, $commitId: String!, $target
}
}
... on RemediableSolveError {
buildExprPath
path
message
isTransient
errorType
Expand All @@ -52,21 +62,11 @@ mutation ($organization: String!, $project: String!, $commitId: String!, $target
parameters
}
}
... on TargetNotFound {
message
requestedTarget
possibleTargets
}
}
}
... on NotFound {
type
message
resource
mayNeedAuthentication
}
}
}`
}
`
}

func (b *evaluate) Vars() (map[string]interface{}, error) {
Expand Down
85 changes: 44 additions & 41 deletions pkg/platform/api/buildplanner/request/mergecommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,55 @@ type mergeCommit struct {
func (b *mergeCommit) Query() string {
return `
mutation ($organization: String!, $project: String!, $targetRef: String!, $otherRef: String!, $strategy: MergeStrategy) {
mergeCommit(input:{organization:$organization, project:$project, targetVcsRef:$targetRef, otherVcsRef:$otherRef, strategy:$strategy}) {
... on MergedCommit {
commit {
__typename
commitId
}
}
... on MergeConflict {
__typename
message
}
... on FastForwardError {
__typename
message
}
... on NoCommonBaseFound {
__typename
message
}
... on NotFound {
__typename
message
mayNeedAuthentication
mergeCommit(
input: {organization: $organization, project: $project, targetVcsRef: $targetRef, otherVcsRef: $otherRef, strategy: $strategy}
) {
... on MergedCommit {
commit {
__typename
commitId
}
}
... on ParseError {
... on Error {
__typename
message
}
... on ValidationError {
... on ErrorWithSubErrors {
__typename
message
}
... on Forbidden {
__typename
message
}
... on HeadOnBranchMoved {
__typename
message
commitId
branchId
}
... on NoChangeSinceLastCommit {
__typename
message
commitId
subErrors {
__typename
buildExprPath
... on RemediableError {
possibleRemediations {
description
suggestedPriority
}
}
... on GenericSolveError {
path
message
isTransient
validationErrors {
error
jsonPath
}
}
... on RemediableSolveError {
path
message
isTransient
errorType
validationErrors {
error
jsonPath
}
suggestedRemediations {
remediationType
command
parameters
}
}
}
}
}
}
Expand Down
Loading

0 comments on commit 8321e42

Please sign in to comment.