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.
FileNotFound
File was not found at the specified path.
FileWrite
Failed to write a file to the filesystem.
InvalidFrontmatter
Invalid frontmatter in a Markdown file.
Fields
MissingFrontmatter
File is missing required frontmatter section.
InvalidYaml
Invalid YAML syntax in frontmatter.
InvalidItemType
Invalid item type value in frontmatter.
Fields
MissingField
Missing required field in frontmatter.
InvalidId
Invalid item ID format.
BrokenReference
Broken reference to non-existent item.
Fields
OrphanItem
Orphan item with no upstream parent.
DuplicateIdentifier
Duplicate identifier found in multiple files.
CircularReference
Circular reference detected in the graph.
InvalidRelationship
Invalid relationship between item types.
Fields
rel_type: RelationshipTypeRelationship type attempted.
InvalidMetadata
Invalid metadata in item.
Fields
UnrecognizedField
Unrecognized field in frontmatter.
RedundantRelationship
Redundant relationship declared on both sides.
ConfigRead
Configuration file could not be read.
InvalidConfig
Configuration file has invalid content.
RepositoryNotFound
Repository path does not exist or is not a directory.
MissingParent
No parent items exist for the given item type.
Fields
ItemNotFound
Item was not found in the knowledge graph.
Fields
InvalidQuery
Query syntax or parameters are invalid.
GitOpenRepository
Failed to open a Git repository.
InvalidGitReference
Git reference (branch, tag, commit) is invalid.
GitReadFile
Failed to read a file from a Git reference.
Fields
Git(String)
Generic Git operation error.
NonInteractiveTerminal
Interactive terminal required but not available.
Cancelled
User cancelled the operation.
InvalidLink
Traceability link points to non-existent item.
EditFailed(String)
Edit operation failed with custom error message.
Io(Error)
Standard I/O error.
Git2(Error)
Git2 library error.
Implementations§
Trait Implementations§
Source§impl Error for SaraError
impl Error for SaraError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for SaraError
impl !RefUnwindSafe for SaraError
impl Send for SaraError
impl Sync for SaraError
impl Unpin for SaraError
impl UnsafeUnpin for SaraError
impl !UnwindSafe for SaraError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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