Debian Codegraph @

src/error.rs

raw symbols SCIP
1 // (c) 2016-2017 Productize SPRL <[email protected]>
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/;
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/;
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/;
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
8
9 /// errors that can happen in this library
10 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
11 pub enum SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
12 /// parse error
13 Parserust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Parse#(ParseErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#),
14 /// other error
15 Otherrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Other#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
16 /// IO Error
17 Iorust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Io#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#),
18 /// Utf8 Error parsing error
19 FromUtf8rust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#FromUtf8#(stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::FromUtf8Errorrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/FromUtf8Error#),
20 /// floating point parsing error
21 Floatrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Float#(numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseFloatErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/dec2flt/ParseFloatError#),
22 /// integer parsing error
23 Intrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Int#(numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#),
24 }
25
26 // TODO: get rid of this again later
27 impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
28 fn fmtrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
29 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
30 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Parserust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Parse#(ref pe) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "symbolic expression parse error: {:?}", pe),
31 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Otherrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Other#(ref s) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "symbolic expression other error: {}", s),
32 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Iorust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Io#(ref e) => e.fmtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error][Display]fmt().(f),
33 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::FromUtf8rust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#FromUtf8#(ref e) => e.fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[FromUtf8Error][Display]fmt().(f),
34 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Floatrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Float#(ref e) => e.fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/dec2flt/impl#[ParseFloatError][Display]fmt().(f),
35 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Intrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Int#(ref e) => e.fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/impl#[ParseIntError][Display]fmt().(f),
36 }
37 }
38 }
39
40 // TODO: get rid of this again later
41 impl errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
42 fn descriptionrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][Error]description().(&self) -> &str {
43 "symbolic expressions error"
44 }
45
46 fn causerust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][Error]cause().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#> {
47 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
48 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Parserust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Parse#(_) | SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Otherrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Other#(_) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
49 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Iorust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Io#(ref e) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e),
50 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::FromUtf8rust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#FromUtf8#(ref e) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e),
51 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Floatrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Float#(ref e) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e),
52 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Intrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Int#(ref e) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e),
53 }
54 }
55 }
56
57 /// detailed symbolic-expression parse error information
58 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
59 pub struct ParseErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError# {
60 msgrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#msg.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
61 linerust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#line.: usize,
62 colrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#col.: usize,
63 }
64
65 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
66 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][`From<io::Error>`]from().(e: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
67 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Iorust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Io#(e)
68 }
69 }
70
71 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
72 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][`From<String>`]from().(e: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
73 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Otherrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Other#(e)
74 }
75 }
76
77 impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a str> for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
78 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][`From<&'a str>`]from().(e: &'a str) -> SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
79 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Otherrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Other#(e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
80 }
81 }
82
83 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::FromUtf8Errorrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/FromUtf8Error#> for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
84 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][`From<string::FromUtf8Error>`]from().(e: stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::FromUtf8Errorrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/FromUtf8Error#) -> SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
85 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::FromUtf8rust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#FromUtf8#(e)
86 }
87 }
88
89 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseFloatErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/dec2flt/ParseFloatError#> for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
90 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][`From<num::ParseFloatError>`]from().(e: numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseFloatErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/dec2flt/ParseFloatError#) -> SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
91 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Floatrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Float#(e)
92 }
93 }
94
95 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#> for SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
96 fn fromrust-analyzer cargo symbolic_expressions 5.0.3 error/impl#[SexpError][`From<num::ParseIntError>`]from().(e: numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#) -> SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError# {
97 SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Intrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Int#(e)
98 }
99 }
100
101 /// utility function that creates a symbolic-expressions Error Result for a parser error
102 pub fn parse_errorrust-analyzer cargo symbolic_expressions 5.0.3 error/parse_error().<T>(line: usize, col: usize, msg: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#> {
103 let pe = ParseErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError# {
104 msgrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#msg.: msg,
105 linerust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#line.: line,
106 colrust-analyzer cargo symbolic_expressions 5.0.3 error/ParseError#col.: col,
107 };
108 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(SexpErrorrust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#::Parserust-analyzer cargo symbolic_expressions 5.0.3 error/SexpError#Parse#(pe))
109 }