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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::io;

#[cfg(feature = "kerberos")]
use libgssapi::error::Error as GssapiError;
use prost::DecodeError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum HdfsError {
    #[error("IO error occurred while communicating with HDFS")]
    IOError(#[from] io::Error),
    #[error("data transfer error")]
    DataTransferError(String),
    #[error("checksums didn't match")]
    ChecksumError,
    #[error("invalid path")]
    InvalidPath(String),
    #[error("invalid argument")]
    InvalidArgument(String),
    #[error("failed to parse URL")]
    UrlParseError(#[from] url::ParseError),
    #[error("file already exists")]
    AlreadyExists(String),
    #[error("operation failed")]
    OperationFailed(String),
    #[error("file not found")]
    FileNotFound(String),
    #[error("blocks not found")]
    BlocksNotFound(String),
    #[error("path is a directory")]
    IsADirectoryError(String),
    #[error("unsupported erasure coding policy")]
    UnsupportedErasureCodingPolicy(String),
    #[error("erasure coding error")]
    ErasureCodingError(String),
    #[error("operation not supported")]
    UnsupportedFeature(String),
    #[error("interal error, this shouldn't happen")]
    InternalError(String),
    #[error("failed to decode RPC response")]
    InvalidRPCResponse(#[from] DecodeError),
    #[error("RPC error")]
    RPCError(String, String),
    #[error("fatal RPC error")]
    FatalRPCError(String, String),
    #[error("SASL error")]
    SASLError(String),
    #[cfg(feature = "kerberos")]
    #[error("GSSAPI error")]
    GSSAPIError(#[from] GssapiError),
    #[error("No valid SASL mechanism found")]
    NoSASLMechanism,
}

pub type Result<T> = std::result::Result<T, HdfsError>;