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 1021 B

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