AgpmError

Enum AgpmError 

Source
pub enum AgpmError {
Show 37 variants GitCommandError { operation: String, stderr: String, }, GitNotFound, GitRepoInvalid { path: String, }, GitAuthenticationFailed { url: String, }, GitCloneFailed { url: String, reason: String, }, GitCheckoutFailed { reference: String, reason: String, }, ConfigError { message: String, }, ManifestNotFound, ManifestParseError { file: String, reason: String, }, ManifestValidationError { reason: String, }, LockfileParseError { file: String, reason: String, }, ResourceNotFound { name: String, }, ResourceFileNotFound { path: String, source_name: String, }, SourceNotFound { name: String, }, SourceUnreachable { name: String, url: String, }, InvalidVersionConstraint { constraint: String, }, VersionNotFound { resource: String, version: String, }, AlreadyInstalled { name: String, }, InvalidResourceType { resource_type: String, }, InvalidResourceStructure { file: String, reason: String, }, CircularDependency { chain: String, }, DependencyResolutionFailed { reason: String, }, NetworkError { operation: String, reason: String, }, FileSystemError { operation: String, path: String, }, PermissionDenied { operation: String, path: String, }, DirectoryNotEmpty { path: String, }, InvalidDependency { name: String, reason: String, }, InvalidResource { name: String, reason: String, }, DependencyNotMet { name: String, required: String, found: String, }, ConfigNotFound { path: String, }, ChecksumMismatch { name: String, expected: String, actual: String, }, PlatformNotSupported { operation: String, }, IoError(Error), TomlError(Error), TomlSerError(Error), SemverError(Error), Other { message: String, },
}
Expand description

The main error type for AGPM operations

This enum represents all possible errors that can occur during AGPM operations. Each variant is designed to provide specific context about the failure and enable appropriate error handling strategies.

§Design Philosophy

  • Specific Error Types: Each error variant represents a specific failure mode
  • Rich Context: Errors include relevant details like file paths, URLs, and reasons
  • User-Friendly: Error messages are written for end users, not just developers
  • Actionable: Most errors provide clear guidance on how to resolve the issue

§Error Categories

§Git Operations

§File System Operations

§Configuration and Parsing

§Resource Management

§Dependency Resolution

§Source Management

§Platform and Network

§Examples

§Pattern Matching on Errors

use agpm_cli::core::AgpmError;

fn handle_error(error: AgpmError) {
    match error {
        AgpmError::GitNotFound => {
            eprintln!("Please install git to use AGPM");
            std::process::exit(1);
        }
        AgpmError::ManifestNotFound => {
            eprintln!("Run 'agpm init' to create a manifest file");
        }
        AgpmError::NetworkError { operation, .. } => {
            eprintln!("Network error during {}: check your connection", operation);
        }
        _ => {
            eprintln!("Unexpected error: {}", error);
        }
    }
}

§Creating Specific Errors

use agpm_cli::core::AgpmError;

// Create a git command error with context
let error = AgpmError::GitCommandError {
    operation: "clone".to_string(),
    stderr: "repository not found".to_string(),
};

// Create a resource not found error
let error = AgpmError::ResourceNotFound {
    name: "my-agent".to_string(),
};

// Create a version constraint error
let error = AgpmError::InvalidVersionConstraint {
    constraint: "~1.x.y".to_string(),
};

Variants§

§

GitCommandError

Git operation failed during execution

This error occurs when a git command returns a non-zero exit code. Common causes include network issues, authentication problems, or invalid git repository states.

§Fields

  • operation: The git operation that failed (e.g., “clone”, “fetch”, “checkout”)
  • stderr: The error output from the git command

Fields

§operation: String

The git operation that failed (e.g., “clone”, “fetch”, “checkout”)

§stderr: String

The error output from the git command

§

GitNotFound

Git executable not found in PATH

This error occurs when AGPM cannot locate the git command in the system PATH. AGPM requires git to be installed and available for repository operations.

Common solutions:

  • Install git from https://git-scm.com/
  • Use a package manager: brew install git, apt install git, etc.
  • Ensure git is in your PATH environment variable
§

GitRepoInvalid

Git repository is invalid or corrupted

This error occurs when a directory exists but doesn’t contain a valid git repository structure (missing .git directory or corrupted).

§Fields

  • path: The path that was expected to contain a git repository

Fields

§path: String

The path that was expected to contain a git repository

§

GitAuthenticationFailed

Git authentication failed for repository access

This error occurs when git cannot authenticate with a remote repository. Common for private repositories or when credentials are missing/expired.

§Fields

  • url: The repository URL that failed authentication

Fields

§url: String

The repository URL that failed authentication

§

GitCloneFailed

Git repository clone failed

Fields

§url: String

The repository URL that failed to clone

§reason: String

The reason for the clone failure

§

GitCheckoutFailed

Git checkout failed

Fields

§reference: String

The git reference (branch, tag, or commit) that failed to checkout

§reason: String

The reason for the checkout failure

§

ConfigError

Configuration error

Fields

§message: String

Description of the configuration error

§

ManifestNotFound

Manifest file (agpm.toml) not found

This error occurs when AGPM cannot locate a agpm.toml file in the current directory or any parent directory up to the filesystem root.

AGPM searches for agpm.toml starting from the current working directory and walking up the directory tree, similar to how git searches for .git.

§

ManifestParseError

Manifest parsing error

Fields

§file: String

Path to the manifest file that failed to parse

§reason: String

Specific reason for the parsing failure

§

ManifestValidationError

Manifest validation error

Fields

§reason: String

Reason why manifest validation failed

§

LockfileParseError

Lockfile parsing error

Fields

§file: String

Path to the lockfile that failed to parse

§reason: String

Specific reason for the parsing failure

§

ResourceNotFound

Resource not found

Fields

§name: String

Name of the resource that could not be found

§

ResourceFileNotFound

Resource file not found in repository

Fields

§path: String

Path to the resource file within the source repository

§source_name: String

Name of the source repository where the file was expected

§

SourceNotFound

Source repository not found

Fields

§name: String

Name of the source repository that is not defined

§

SourceUnreachable

Source repository unreachable

Fields

§name: String

Name of the source repository

§url: String

URL of the unreachable repository

§

InvalidVersionConstraint

Invalid version constraint

Fields

§constraint: String

The invalid version constraint string

§

VersionNotFound

Version not found

Fields

§resource: String

Name of the resource for which the version was not found

§version: String

The version string that could not be found

§

AlreadyInstalled

Resource already installed

Fields

§name: String

Name of the resource that is already installed

§

InvalidResourceType

Invalid resource type

Fields

§resource_type: String

The invalid resource type that was specified

§

InvalidResourceStructure

Invalid resource structure

Fields

§file: String

Path to the file with invalid resource structure

§reason: String

Reason why the resource structure is invalid

§

CircularDependency

Circular dependency detected in dependency graph

This error occurs when resources depend on each other in a cycle, making it impossible to determine installation order.

Example: A depends on B, B depends on C, C depends on A

§Fields

  • chain: The dependency chain showing the circular reference

Fields

§chain: String

String representation of the circular dependency chain

§

DependencyResolutionFailed

Dependency resolution failed

Fields

§reason: String

Reason why dependency resolution failed

§

NetworkError

Network error

Fields

§operation: String

The network operation that failed

§reason: String

Reason for the network failure

§

FileSystemError

File system error

Fields

§operation: String

The file system operation that failed

§path: String

Path where the file system error occurred

§

PermissionDenied

Permission denied

Fields

§operation: String

The operation that was denied due to insufficient permissions

§path: String

Path where permission was denied

§

DirectoryNotEmpty

Directory not empty

Fields

§path: String

Path to the directory that is not empty

§

InvalidDependency

Invalid dependency specification

Fields

§name: String

Name of the invalid dependency

§reason: String

Reason why the dependency specification is invalid

§

InvalidResource

Invalid resource content

Fields

§name: String

Name of the invalid resource

§reason: String

Reason why the resource content is invalid

§

DependencyNotMet

Dependency not met

Fields

§name: String

Name of the dependency that is not satisfied

§required: String

The required version constraint

§found: String

The version that was actually found

§

ConfigNotFound

Config file not found

Fields

§path: String

Path to the configuration file that was not found

§

ChecksumMismatch

Checksum mismatch

Fields

§name: String

Name of the resource with checksum mismatch

§expected: String

The expected checksum value

§actual: String

The actual checksum that was computed

§

PlatformNotSupported

Platform not supported

Fields

§operation: String

The operation that is not supported on this platform

§

IoError(Error)

IO error

§

TomlError(Error)

TOML parsing error

§

TomlSerError(Error)

TOML serialization error

§

SemverError(Error)

Semver parsing error

§

Other

Other error

Fields

§message: String

Generic error message

Trait Implementations§

Source§

impl Clone for AgpmError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgpmError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AgpmError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for AgpmError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for AgpmError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for AgpmError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for AgpmError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for AgpmError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl IntoAnyhowWithContext for AgpmError

Source§

fn into_anyhow_with_context(self, context: ErrorContext) -> Error

Convert the error to an anyhow::Error with the provided context

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,