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