51 lines
932 B
Go
51 lines
932 B
Go
|
|
package errors
|
||
|
|
|
||
|
|
import "fmt"
|
||
|
|
|
||
|
|
// GitError represents errors from git operations
|
||
|
|
type GitError struct {
|
||
|
|
Command string
|
||
|
|
Err error
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *GitError) Error() string {
|
||
|
|
return fmt.Sprintf("git %s failed: %v", e.Command, e.Err)
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *GitError) Unwrap() error {
|
||
|
|
return e.Err
|
||
|
|
}
|
||
|
|
|
||
|
|
// APIError represents errors from Grok API calls
|
||
|
|
type APIError struct {
|
||
|
|
StatusCode int
|
||
|
|
Message string
|
||
|
|
Err error
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *APIError) Error() string {
|
||
|
|
if e.StatusCode > 0 {
|
||
|
|
return fmt.Sprintf("API error (status %d): %s", e.StatusCode, e.Message)
|
||
|
|
}
|
||
|
|
return fmt.Sprintf("API error: %s", e.Message)
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *APIError) Unwrap() error {
|
||
|
|
return e.Err
|
||
|
|
}
|
||
|
|
|
||
|
|
// FileError represents file operation errors
|
||
|
|
type FileError struct {
|
||
|
|
Path string
|
||
|
|
Op string
|
||
|
|
Err error
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *FileError) Error() string {
|
||
|
|
return fmt.Sprintf("file %s failed for %s: %v", e.Op, e.Path, e.Err)
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *FileError) Unwrap() error {
|
||
|
|
return e.Err
|
||
|
|
}
|