feat: add OperationFailedError with actionable hints
The Kanboard API returns only true/false for many operations without explaining why they failed. Added OperationFailedError type that includes operation details and hints about possible causes. Updated MoveTaskPosition and MoveTaskToProject to use this new error type, providing users with actionable debugging information instead of generic "failed to move task" messages. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
508c3ac6d2
commit
449cd2626c
6 changed files with 131 additions and 5 deletions
19
tasks.go
19
tasks.go
|
|
@ -143,7 +143,15 @@ func (c *Client) MoveTaskPosition(ctx context.Context, projectID, taskID, column
|
|||
}
|
||||
|
||||
if !success {
|
||||
return fmt.Errorf("moveTaskPosition: failed to move task %d", taskID)
|
||||
return &OperationFailedError{
|
||||
Operation: fmt.Sprintf("moveTaskPosition(task=%d, column=%d, project=%d)", taskID, columnID, projectID),
|
||||
Hints: []string{
|
||||
"task may not exist",
|
||||
"column may not belong to project",
|
||||
"insufficient permissions",
|
||||
"task may already be in target position",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -162,7 +170,14 @@ func (c *Client) MoveTaskToProject(ctx context.Context, taskID, projectID int) e
|
|||
}
|
||||
|
||||
if !success {
|
||||
return fmt.Errorf("moveTaskToProject: failed to move task %d to project %d", taskID, projectID)
|
||||
return &OperationFailedError{
|
||||
Operation: fmt.Sprintf("moveTaskToProject(task=%d, project=%d)", taskID, projectID),
|
||||
Hints: []string{
|
||||
"task may not exist",
|
||||
"target project may not exist",
|
||||
"insufficient permissions",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue