Skip to main content

BatlessError

Enum BatlessError 

Source
pub enum BatlessError {
Show 13 variants FileNotFound { path: String, suggestions: Vec<String>, }, FileReadError { path: String, source: Error, }, PermissionDenied { path: String, help: String, }, HighlightError { message: String, operation: String, source_error: Option<String>, }, ThemeNotFound { theme: String, suggestions: Vec<String>, }, LanguageNotFound { language: String, suggestions: Vec<String>, }, LanguageDetectionError { path: String, details: String, }, EncodingError { path: String, details: String, }, ProcessingError { message: String, path: Option<String>, help: Option<String>, }, ConfigurationError { message: String, help: Option<String>, }, JsonSerializationError(Error), OutputError(String), IoError(Error),
}
Expand description

Main error type for batless operations

Variants§

§

FileNotFound

File system related errors

Fields

§path: String
§suggestions: Vec<String>
§

FileReadError

Fields

§path: String
§source: Error
§

PermissionDenied

Fields

§path: String
§help: String
§

HighlightError

Syntax highlighting errors

Fields

§message: String
§operation: String
§source_error: Option<String>
§

ThemeNotFound

Fields

§theme: String
§suggestions: Vec<String>
§

LanguageNotFound

Fields

§language: String
§suggestions: Vec<String>
§

LanguageDetectionError

Fields

§path: String
§details: String
§

EncodingError

Processing errors

Fields

§path: String
§details: String
§

ProcessingError

Fields

§message: String
§

ConfigurationError

Fields

§message: String
§

JsonSerializationError(Error)

Output formatting errors

§

OutputError(String)

§

IoError(Error)

Generic I/O errors

Implementations§

Source§

impl BatlessError

Source

pub fn error_code(&self) -> ErrorCode

Get the error code for this error

Source

pub fn file_not_found_with_suggestions(path: String) -> Self

Create a FileNotFound error with file suggestions

Source

pub fn theme_not_found_with_suggestions( theme: String, available_themes: &[String], ) -> Self

Create a ThemeNotFound error with theme suggestions

Source

pub fn language_not_found_with_suggestions( language: String, available_languages: &[String], ) -> Self

Create a LanguageNotFound error with language suggestions

Source

pub fn permission_denied_with_help(path: String) -> Self

Create a PermissionDenied error with helpful suggestions

Source

pub fn config_error_with_help(message: String, help: Option<String>) -> Self

Create a ConfigurationError with helpful suggestions

Source

pub fn highlight_error( message: impl Into<String>, operation: impl Into<String>, ) -> Self

Create a HighlightError with context about what operation failed

Source

pub fn highlight_error_with_source( message: impl Into<String>, operation: impl Into<String>, source: impl Display, ) -> Self

Create a HighlightError with source error information

Source

pub fn language_detection_error( path: impl Into<String>, details: impl Into<String>, ) -> Self

Create a LanguageDetectionError with file path context

Source

pub fn processing_error(message: impl Into<String>) -> Self

Create a ProcessingError with context

Source

pub fn processing_error_for_path( path: impl Into<String>, message: impl Into<String>, ) -> Self

Create a ProcessingError with file path context

Source

pub fn processing_error_with_help( path: Option<String>, message: impl Into<String>, help: impl Into<String>, ) -> Self

Create a ProcessingError with full context

Source

pub fn encoding_error( path: impl Into<String>, details: impl Into<String>, ) -> Self

Create an EncodingError for a file

Source

pub fn from_io_error(err: Error, path: impl Into<String>) -> Self

Create appropriate error from an IO error with file context

This examines the IO error kind to return the most specific error type:

  • NotFound -> FileNotFound with suggestions
  • PermissionDenied -> PermissionDenied with help
  • Other -> FileReadError with source

Trait Implementations§

Source§

impl Debug for BatlessError

Source§

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

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

impl Display for BatlessError

Source§

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

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

impl Error for BatlessError

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 BatlessError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for BatlessError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.