Skip to main content

SaraError

Enum SaraError 

Source
pub enum SaraError {
Show 33 variants FileRead { path: PathBuf, source: Error, }, FileNotFound { path: PathBuf, }, FileWrite { path: PathBuf, source: Error, }, InvalidFrontmatter { file: PathBuf, reason: String, }, MissingFrontmatter { file: PathBuf, }, InvalidYaml { file: PathBuf, reason: String, }, InvalidItemType { file: PathBuf, value: String, }, MissingField { field: String, file: PathBuf, }, InvalidId { id: String, reason: String, }, BrokenReference { from: ItemId, to: ItemId, }, OrphanItem { id: ItemId, item_type: ItemType, }, DuplicateIdentifier { id: ItemId, }, CircularReference { cycle: String, }, InvalidRelationship { from_id: ItemId, to_id: ItemId, from_type: ItemType, to_type: ItemType, rel_type: RelationshipType, }, InvalidMetadata { file: String, reason: String, }, UnrecognizedField { field: String, file: String, }, RedundantRelationship { from_id: ItemId, to_id: ItemId, }, ConfigRead { path: PathBuf, reason: String, }, InvalidConfig { path: PathBuf, reason: String, }, RepositoryNotFound { path: PathBuf, }, MissingParent { item_type: String, parent_type: String, }, ItemNotFound { id: String, suggestions: Vec<String>, }, InvalidQuery { reason: String, }, GitOpenRepository { path: PathBuf, reason: String, }, InvalidGitReference { reference: String, }, GitReadFile { path: PathBuf, reference: String, reason: String, }, Git(String), NonInteractiveTerminal, Cancelled, InvalidLink { id: String, }, EditFailed(String), Io(Error), Git2(Error),
}
Expand description

Main error type for sara-core operations.

Consolidates all error categories into a single type with clear variants. Uses thiserror for automatic Display and Error trait implementations.

§Errors

This enum categorizes all possible errors that can occur during SARA operations. Each variant includes contextual information to help diagnose the issue.

§Examples

use sara_core::error::SaraError;
use std::path::PathBuf;

// File not found
let err = SaraError::FileNotFound { path: PathBuf::from("missing.md") };

// Parse error with context
let err = SaraError::InvalidFrontmatter {
    file: PathBuf::from("doc.md"),
    reason: "Missing 'id' field".to_string(),
};

Variants§

§

FileRead

Failed to read a file from the filesystem.

Fields

§path: PathBuf

Path to the file that couldn’t be read.

§source: Error

Underlying I/O error.

§

FileNotFound

File was not found at the specified path.

Fields

§path: PathBuf

Path to the missing file.

§

FileWrite

Failed to write a file to the filesystem.

Fields

§path: PathBuf

Path to the file that couldn’t be written.

§source: Error

Underlying I/O error.

§

InvalidFrontmatter

Invalid frontmatter in a Markdown file.

Fields

§file: PathBuf

Path to the file with invalid frontmatter.

§reason: String

Description of what’s wrong with the frontmatter.

§

MissingFrontmatter

File is missing required frontmatter section.

Fields

§file: PathBuf

Path to the file without frontmatter.

§

InvalidYaml

Invalid YAML syntax in frontmatter.

Fields

§file: PathBuf

Path to the file with invalid YAML.

§reason: String

YAML parsing error details.

§

InvalidItemType

Invalid item type value in frontmatter.

Fields

§file: PathBuf

Path to the file with the invalid type.

§value: String

The invalid type value encountered.

§

MissingField

Missing required field in frontmatter.

Fields

§field: String

The field that was missing.

§file: PathBuf

Path to the file.

§

InvalidId

Invalid item ID format.

Fields

§id: String

The invalid ID.

§reason: String

Why the ID is invalid.

§

BrokenReference

Broken reference to non-existent item.

Fields

§from: ItemId

The item with the broken reference.

§to: ItemId

The non-existent item being referenced.

§

OrphanItem

Orphan item with no upstream parent.

Fields

§id: ItemId

The orphaned item ID.

§item_type: ItemType

The item type.

§

DuplicateIdentifier

Duplicate identifier found in multiple files.

Fields

§id: ItemId

The duplicated ID.

§

CircularReference

Circular reference detected in the graph.

Fields

§cycle: String

Description of the cycle.

§

InvalidRelationship

Invalid relationship between item types.

Fields

§from_id: ItemId

Source item ID.

§to_id: ItemId

Target item ID.

§from_type: ItemType

Source item type.

§to_type: ItemType

Target item type.

§rel_type: RelationshipType

Relationship type attempted.

§

InvalidMetadata

Invalid metadata in item.

Fields

§file: String

File containing the invalid metadata.

§reason: String

Description of the metadata issue.

§

UnrecognizedField

Unrecognized field in frontmatter.

Fields

§field: String

The unrecognized field name.

§file: String

File containing the field.

§

RedundantRelationship

Redundant relationship declared on both sides.

Fields

§from_id: ItemId

First item ID.

§to_id: ItemId

Second item ID.

§

ConfigRead

Configuration file could not be read.

Fields

§path: PathBuf

Path to the config file.

§reason: String

Reason for the failure.

§

InvalidConfig

Configuration file has invalid content.

Fields

§path: PathBuf

Path to the config file.

§reason: String

Description of the configuration error.

§

RepositoryNotFound

Repository path does not exist or is not a directory.

Fields

§path: PathBuf

Path that was expected to be a repository.

§

MissingParent

No parent items exist for the given item type.

Fields

§item_type: String

The item type that requires a parent.

§parent_type: String

The parent type that is missing.

§

ItemNotFound

Item was not found in the knowledge graph.

Fields

§id: String

The item ID that wasn’t found.

§suggestions: Vec<String>

Suggested similar item IDs (fuzzy matches).

§

InvalidQuery

Query syntax or parameters are invalid.

Fields

§reason: String

Description of what’s wrong with the query.

§

GitOpenRepository

Failed to open a Git repository.

Fields

§path: PathBuf

Path to the repository.

§reason: String

Error from git2.

§

InvalidGitReference

Git reference (branch, tag, commit) is invalid.

Fields

§reference: String

The invalid reference string.

§

GitReadFile

Failed to read a file from a Git reference.

Fields

§path: PathBuf

Path to the file in the repository.

§reference: String

Git reference (commit, branch, tag).

§reason: String

Error details.

§

Git(String)

Generic Git operation error.

§

NonInteractiveTerminal

Interactive terminal required but not available.

§

Cancelled

User cancelled the operation.

Traceability link points to non-existent item.

Fields

§id: String

The invalid item ID.

§

EditFailed(String)

Edit operation failed with custom error message.

§

Io(Error)

Standard I/O error.

§

Git2(Error)

Git2 library error.

Implementations§

Source§

impl SaraError

Source

pub fn format_suggestions(&self) -> Option<String>

Formats suggestions as a user-friendly message.

Returns None if this is not an ItemNotFound error or if there are no suggestions.

Trait Implementations§

Source§

impl Debug for SaraError

Source§

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

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

impl Display for SaraError

Source§

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

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

impl Error for SaraError

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 SaraError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SaraError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl Serialize for SaraError

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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, 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