File size: 809 Bytes
d90101d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::string::FromUtf8Error;

use thiserror::Error;

/// Error type for file operations
#[derive(Error, Debug)]
pub enum Error {
    #[error("Binary files are not supported. File detected as {0}")]
    BinaryFileNotSupported(String),

    #[error("Start position {start} is beyond the file size of {total} characters")]
    StartBeyondFileSize { start: u64, total: u64 },

    #[error("Start position {start} and end position {end} must be 1-based (inclusive)")]
    IndexStartingWithZero { start: u64, end: u64 },

    #[error("Start position {start} is greater than end position {end}")]
    StartGreaterThanEnd { start: u64, end: u64 },

    #[error("UTF-8 validation failed: {0}")]
    Utf8ValidationFailed(#[from] FromUtf8Error),

    #[error("I/O error: {0}")]
    IoError(#[from] std::io::Error),
}