Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

error.rs 1.1 KB

You have to be logged in to leave a comment. Sign In
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
  1. use derive_more::*;
  2. use std::io;
  3. use std::fmt;
  4. use std::error::Error;
  5. use crossbeam_channel;
  6. use glob;
  7. #[derive(Debug, From)]
  8. pub enum BDError {
  9. IO(io::Error),
  10. XML(quick_xml::Error),
  11. UTF8(std::str::Utf8Error),
  12. RDFNT(ntriple::parser::ParseError),
  13. PSQL(postgres::error::Error),
  14. Boxed(Box<Error>),
  15. Misc(String)
  16. }
  17. impl fmt::Display for BDError {
  18. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  19. write!(f, "{:?}", self)
  20. }
  21. }
  22. impl From<log::SetLoggerError> for BDError {
  23. fn from(_sle: log::SetLoggerError) -> BDError {
  24. err("cannot set logger")
  25. }
  26. }
  27. macro_rules! wrap_error {
  28. ($et:ty) => {
  29. impl From<$et> for BDError {
  30. fn from(err: $et) -> BDError {
  31. BDError::Boxed(Box::new(err))
  32. }
  33. }
  34. }
  35. }
  36. wrap_error!(std::env::VarError);
  37. wrap_error!(zip::result::ZipError);
  38. wrap_error!(crossbeam_channel::RecvError);
  39. wrap_error!(glob::GlobError);
  40. wrap_error!(glob::PatternError);
  41. pub fn err(msg: &str) -> BDError {
  42. BDError::Misc(msg.to_string())
  43. }
  44. /// Typedef for all-purpose result type.
  45. pub type Result<R> = std::result::Result<R, BDError>;
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...