1#[derive(Debug)]
2pub enum DgraphError {
3 Finished,
4 EmptyTransaction,
5 ReadOnly,
6 StartTsMismatch,
7 GrpcError(grpc::Error),
8 Unknown,
9}
10
11impl std::fmt::Display for DgraphError {
12 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13 match self {
14 DgraphError::Finished => write!(f, "Dgraph client already finished"),
15 DgraphError::EmptyTransaction => write!(f, "EmptyTransaction"),
16 DgraphError::ReadOnly => write!(f, "Can not mutate, set to read only"),
17 DgraphError::StartTsMismatch => write!(f, "StartTsMismatch"),
18 DgraphError::GrpcError(_) => write!(f, "GrpcError"),
19 DgraphError::Unknown => write!(f, "UnknownError"),
20 }
21 }
22}
23
24impl std::error::Error for DgraphError {
25
26}
27
28impl From<grpc::Error> for DgraphError {
29 fn from(e: grpc::Error) -> DgraphError {
30 DgraphError::GrpcError(e)
31 }
32}