Added create and delete operations for projects and boards with validation and error handling

This commit is contained in:
Steve Cliff
2026-02-17 07:47:49 +00:00
parent c03d05734a
commit c15a48cda3
15 changed files with 571 additions and 4 deletions
+36
View File
@@ -0,0 +1,36 @@
package cmd
import (
"fmt"
"git.franklin.lab/steve.cliff/pcli/model"
)
// friendlyAPIError translates APIError status codes into human-readable messages with operation context.
func friendlyAPIError(err error, operation string, permissionHint string) error {
if err == nil {
return nil
}
// Check if it's an APIError
apiErr, ok := err.(*model.APIError)
if !ok {
// Not an API error, return as-is
return err
}
switch apiErr.StatusCode {
case 401:
return fmt.Errorf("%s: authentication failed — check your API key", operation)
case 403:
if permissionHint != "" {
return fmt.Errorf("%s: permission denied (%s)", operation, permissionHint)
}
return fmt.Errorf("%s: permission denied", operation)
case 404:
return fmt.Errorf("%s: not found — the resource may not exist or you may not have access to it", operation)
default:
// Unknown status code, return original error
return err
}
}