ente/cli/internal/api/api_error.go
2024-03-01 12:39:01 +05:30

28 lines
461 B
Go

package api
import (
"fmt"
"strings"
)
type ApiError struct {
Message string
StatusCode int
}
func (e *ApiError) Error() string {
return fmt.Sprintf("status %d with err: %s", e.StatusCode, e.Message)
}
func IsApiError(err error) bool {
_, ok := err.(*ApiError)
return ok
}
func IsFileNotInAlbumError(err error) bool {
if apiErr, ok := err.(*ApiError); ok {
return strings.Contains(apiErr.Message, "FILE_NOT_FOUND_IN_ALBUM")
}
return false
}