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
#[derive(Debug)]
pub enum DgraphError {
    Finished,
    EmptyTransaction,
    ReadOnly,
    StartTsMismatch,
    GrpcError(grpc::Error),
    Unknown,
}

impl std::fmt::Display for DgraphError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            DgraphError::Finished => write!(f, "Dgraph client already finished"),
            DgraphError::EmptyTransaction => write!(f, "EmptyTransaction"),
            DgraphError::ReadOnly => write!(f, "Can not mutate, set to read only"),
            DgraphError::StartTsMismatch => write!(f, "StartTsMismatch"),
            DgraphError::GrpcError(_) => write!(f, "GrpcError"),
            DgraphError::Unknown => write!(f, "UnknownError"),
        }
    }
}

impl std::error::Error for DgraphError {

}

impl From<grpc::Error> for DgraphError {
    fn from(e: grpc::Error) -> DgraphError {
        DgraphError::GrpcError(e)
    }
}