errors.rs 866 Bytes
Newer Older
nhynes committed
1 2 3 4 5 6
#[cfg(target_env = "sgx")]
use alloc::alloc;
#[cfg(not(target_env = "sgx"))]
use std::alloc;
use std::num;

7
use crate::common::errors as common_errors;
nhynes committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use ndarray;
use serde_json;

error_chain! {
  errors {
    GraphFormatError(msg: String) {
      description("unable to load graph")
      display("could not load graph json: {}", msg)
    }

    LoadGraphParamsError(msg: String) {
      description("unable to load graph params")
      display("could not load graph params: {}", msg)
    }
  }
  foreign_links {
    Alloc(alloc::AllocErr);
    GraphDeserialize(serde_json::Error);
    ParseInt(num::ParseIntError);
    ShapeError(ndarray::ShapeError);
28
    CommonError(common_errors::Error);
nhynes committed
29 30 31 32
  }
}

impl From<alloc::LayoutErr> for Error {
33 34 35
    fn from(_err: alloc::LayoutErr) -> Error {
        Error::from_kind(ErrorKind::Msg("Layout error".to_string()))
    }
nhynes committed
36
}