Documentation
¶
Overview ¶
Package errors provides standardized error types and exit codes for gpd.
Index ¶
- Constants
- Variables
- type APIError
- func (e *APIError) Error() string
- func (e *APIError) ExitCode() int
- func (e *APIError) WithDetails(details interface{}) *APIError
- func (e *APIError) WithHTTPStatus(status int) *APIError
- func (e *APIError) WithHint(hint string) *APIError
- func (e *APIError) WithOperation(operation string) *APIError
- func (e *APIError) WithRetryAfter(seconds int) *APIError
- func (e *APIError) WithService(service string) *APIError
- type ErrorCode
Constants ¶
View Source
const ( ExitSuccess = 0 // Command succeeded ExitGeneralError = 1 // Other API errors ExitAuthFailure = 2 // Authentication failures ExitPermissionDenied = 3 // Permission denied ExitValidationError = 4 // Input validation errors ExitRateLimited = 5 // Rate limit exceeded (HTTP 429 or quota) ExitNetworkError = 6 // Network errors (DNS, TLS, timeouts) ExitNotFound = 7 // Resource not found ExitConflict = 8 // Conflicts (edit exists, file lock contention) )
Exit codes for gpd CLI following the requirements specification.
Variables ¶
View Source
var ( ErrAuthNotConfigured = NewAPIError(CodeAuthFailure, "authentication not configured"). WithHint("Provide --key, set GPD_SERVICE_ACCOUNT_KEY, or set GOOGLE_APPLICATION_CREDENTIALS") ErrServiceAccountInvalid = NewAPIError(CodeAuthFailure, "invalid service account key"). WithHint("Ensure the service account key file is valid JSON and contains required fields") ErrPermissionDenied = NewAPIError(CodePermissionDenied, "permission denied"). WithHint("Ensure the service account has required permissions in Google Play Console") ErrPackageRequired = NewAPIError(CodeValidationError, "package name is required"). WithHint("Provide --package flag or set default package in config") ErrTrackInvalid = NewAPIError(CodeValidationError, "invalid track name"). WithHint("Valid tracks are: internal, alpha, beta, production") ErrEditConflict = NewAPIError(CodeConflict, "edit transaction conflict"). WithHint("Another process may be using this edit. Wait and retry, or use a different --edit-id") ErrFileLockTimeout = NewAPIError(CodeConflict, "file lock acquisition timeout"). WithHint("Another gpd process may be running. Wait for it to complete or check for stale locks") )
Common errors with hints.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Hint string `json:"hint,omitempty"`
Details interface{} `json:"details,omitempty"`
HTTPStatus int `json:"httpStatus,omitempty"`
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty"`
Service string `json:"service,omitempty"`
Operation string `json:"operation,omitempty"`
}
APIError represents a structured error response.
func ClassifyAuthError ¶
func NewAPIError ¶
NewAPIError creates a new APIError with the given parameters.
func (*APIError) WithDetails ¶
WithDetails adds details to the error.
func (*APIError) WithHTTPStatus ¶
WithHTTPStatus adds HTTP status to the error.
func (*APIError) WithOperation ¶
WithOperation adds operation name to the error.
func (*APIError) WithRetryAfter ¶
WithRetryAfter adds retry-after seconds to the error.
func (*APIError) WithService ¶
WithService adds service name to the error.
type ErrorCode ¶
type ErrorCode string
ErrorCode represents a string error code for structured error responses.
const ( CodeSuccess ErrorCode = "SUCCESS" CodeGeneralError ErrorCode = "GENERAL_ERROR" CodeAuthFailure ErrorCode = "AUTH_FAILURE" CodePermissionDenied ErrorCode = "PERMISSION_DENIED" CodeValidationError ErrorCode = "VALIDATION_ERROR" CodeRateLimited ErrorCode = "RATE_LIMITED" CodeNetworkError ErrorCode = "NETWORK_ERROR" CodeNotFound ErrorCode = "NOT_FOUND" CodeConflict ErrorCode = "CONFLICT" )
func FromHTTPStatus ¶
FromHTTPStatus creates an appropriate error code from HTTP status.
Click to show internal directories.
Click to hide internal directories.