Debian Codegraph @

src/error.rs

raw symbols SCIP
1 //! A module for handling errors in `apt-sources` crate of `deb822-rs` project.
2 //! It intends to address error handling in meaningful manner, less vague than just passing
3 //! `String` as error.
4
5 /// Errors for APT sources parsing and conversion to/from [`super::Repository`] or [`super::legacy::LegacyRepository`]
6 #[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:)]
7 pub enum RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError# {
8 /// Invalid repository format
9 InvalidFormatrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidFormat#,
10 /// Invalid repository URI
11 InvalidUrirust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidUri#,
12 /// Missing repository URI - mandatory
13 MissingUrirust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#MissingUri#,
14 /// Unrecognized repository type
15 InvalidTyperust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidType#,
16 /// The `Signed-By` field is incorrect
17 InvalidSignaturerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidSignature#,
18 /// The Yes/No/Force field has invalid/unexpected value
19 YesNoForceFieldInvalidrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#YesNoForceFieldInvalid#,
20 /// The Yes/No field has invalid/unexpected value
21 YesNoFieldInvalidrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#YesNoFieldInvalid#,
22 /// The field in the parsed data is not recognized (check `man sources.list`)
23 UnrecognizedFieldNamerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#UnrecognizedFieldName#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
24 /// Errors in lossy serializer or deserializer
25 Lossyrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Lossy#(deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::Errorrust-analyzer cargo deb822-fast 0.2.3 Error#),
26 /// I/O Error
27 Iorust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Io#(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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#),
28 /// URL Error
29 Urlrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Url#(urlrust-analyzer cargo url 2.5.8 crate/::ParseErrorrust-analyzer cargo url 2.5.8 parser/ParseError#),
30 }
31
32 /// Errors that can occur when loading repositories from directories
33 #[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:)]
34 pub enum LoadErrorrust-analyzer cargo apt-sources 0.3.0 error/LoadError# {
35 /// Failed to read a file
36 Iorust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io# {
37 /// The path that failed to be read
38 pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io#path.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
39 /// The underlying I/O error
40 errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io#error.: 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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#,
41 },
42 /// Failed to parse a file
43 Parserust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse# {
44 /// The path that failed to be parsed
45 pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse#path.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
46 /// The parsing error message
47 errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse#error.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
48 },
49 /// Failed to read directory entries
50 DirectoryReadrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead# {
51 /// The directory path that failed to be read
52 pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead#path.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
53 /// The underlying I/O error
54 errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead#error.: 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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#,
55 },
56 #[cfg(not(feature = "legacy"))]
57 /// The support for `legacy` format hadn't been enabled at build time
58 UnsupportedLegacyFormat,
59 }
60
61 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError# {
62 fn fromrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<std::io::Error>`]from().(e: 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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<std::io::Error>`] {
63 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<std::io::Error>`]::Iorust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Io#(e)
64 }
65 }
66
67 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<urlrust-analyzer cargo url 2.5.8 crate/::ParseErrorrust-analyzer cargo url 2.5.8 parser/ParseError#> for RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError# {
68 fn fromrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<url::ParseError>`]from().(e: urlrust-analyzer cargo url 2.5.8 crate/::ParseErrorrust-analyzer cargo url 2.5.8 parser/ParseError#) -> Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<url::ParseError>`] {
69 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<url::ParseError>`]::Urlrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Url#(e)
70 }
71 }
72
73 impl 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError# {
74 fn fmtrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]fmt().(&self, f: &mut 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/::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#<(), 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/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
75 // Spare longer messages to split lines by `rustfmt`
76 const YNFERRMSGrust-analyzer cargo apt-sources 0.3.0 error/YNFERRMSG.: &str = "The field requiring only `Yes`/`No`/`Force` values is incorrect";
77 const YNERRMSGrust-analyzer cargo apt-sources 0.3.0 error/YNERRMSG.: &str = "The field requiring only `Yes`/`No` values is incorrect";
78 match self {
79 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::InvalidFormatrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidFormat# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Invalid repository format"),
80 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::InvalidUrirust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidUri# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Invalid repository URI"),
81 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::MissingUrirust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#MissingUri# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Missing repository URI"),
82 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::InvalidTyperust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidType# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Invalid repository type"),
83 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::InvalidSignaturerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidSignature# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "The field `Signed-By` is incorrect"),
84 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::YesNoForceFieldInvalidrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#YesNoForceFieldInvalid# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(YNFERRMSGrust-analyzer cargo apt-sources 0.3.0 error/YNFERRMSG.),
85 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::YesNoFieldInvalidrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#YesNoFieldInvalid# => f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(YNERRMSGrust-analyzer cargo apt-sources 0.3.0 error/YNERRMSG.),
86 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::UnrecognizedFieldNamerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#UnrecognizedFieldName#(name) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
87 f,
88 "Unrecognized field name: {name} (check `man sources.list`)"
89 ),
90 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::Lossyrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Lossy#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Lossy parser error: {e}"),
91 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::Iorust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Io#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "IO error: {e}"),
92 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][Display]::Urlrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Url#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "URL parse error: {e}"),
93 }
94 }
95 }
96
97 impl 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for LoadErrorrust-analyzer cargo apt-sources 0.3.0 error/LoadError# {
98 fn fmtrust-analyzer cargo apt-sources 0.3.0 error/impl#[LoadError][Display]fmt().(&self, f: &mut 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/::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#<(), 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/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
99 match self {
100 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[LoadError][Display]::Iorust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io# { pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io#path., errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io#error. } => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Failed to read {}: {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), error),
101 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[LoadError][Display]::Parserust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse# { pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse#path., errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse#error. } => {
102 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Failed to parse {}: {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), error)
103 }
104 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[LoadError][Display]::DirectoryReadrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead# { pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead#path., errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead#error. } => {
105 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Failed to read directory {}: {}", path.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), error)
106 }
107 #[cfg(not(feature = "legacy"))]
108 Selfrust-analyzer cargo apt-sources 0.3.0 error/impl#[LoadError][Display]::UnsupportedLegacyFormat => {
109 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
110 f,
111 "The support for `legacy` format hadn't been enabled at build time"
112 )
113 }
114 }
115 }
116 }
117
118 impl 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/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError# {}
119 impl 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/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for LoadErrorrust-analyzer cargo apt-sources 0.3.0 error/LoadError# {}
120
121 #[cfg(test)]
122 mod testsrust-analyzer cargo apt-sources 0.3.0 error/tests/ {
123 use superrust-analyzer cargo apt-sources 0.3.0 error/::*;
124
125 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
126 fn test_repository_error_displayrust-analyzer cargo apt-sources 0.3.0 error/tests/test_repository_error_display().() {
127 // Test each error variant
128 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
129 RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::InvalidFormatrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidFormat#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
130 "Invalid repository format"
131 );
132 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
133 RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::InvalidUrirust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidUri#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
134 "Invalid repository URI"
135 );
136 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
137 RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::MissingUrirust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#MissingUri#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
138 "Missing repository URI"
139 );
140 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
141 RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::InvalidTyperust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidType#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
142 "Invalid repository type"
143 );
144 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
145 RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::InvalidSignaturerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidSignature#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
146 "The field `Signed-By` is incorrect"
147 );
148
149 // Test unrecognized field name includes the field name
150 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
151 RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::UnrecognizedFieldNamerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#UnrecognizedFieldName#("foo-bar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
152 "Unrecognized field name: foo-bar (check `man sources.list`)"
153 );
154
155 // Test lossy error
156 let lossy_err = deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::Errorrust-analyzer cargo deb822-fast 0.2.3 Error#::UnexpectedEofrust-analyzer cargo deb822-fast 0.2.3 Error#UnexpectedEof#;
157 let repo_err = RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::Lossyrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#Lossy#(lossy_err);
158 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(repo_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Lossy parser error:"));
159
160 // Test IO error
161 let io_err = 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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(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/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::NotFoundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#NotFound#, "file not found");
162 let repo_err = RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::fromrust-analyzer cargo apt-sources 0.3.0 error/impl#[RepositoryError][`From<std::io::Error>`]from().(io_err);
163 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(repo_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("IO error:"));
164 }
165
166 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
167 fn test_load_error_displayrust-analyzer cargo apt-sources 0.3.0 error/tests/test_load_error_display().() {
168 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
169
170 // Test IO error
171 let io_err = 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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(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/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::NotFoundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#NotFound#, "file not found");
172 let load_err = LoadErrorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#::Iorust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io# {
173 pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io#path.: PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/test/path"),
174 errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Io#error.: io_err,
175 };
176 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(load_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Failed to read /test/path"));
177 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(load_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("file not found"));
178
179 // Test Parse error
180 let parse_err = LoadErrorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#::Parserust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse# {
181 pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse#path.: PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/test/file.list"),
182 errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#Parse#error.: "Invalid format".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
183 };
184 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_err
185 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
186 .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Failed to parse /test/file.list"));
187 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Invalid format"));
188
189 // Test DirectoryRead error
190 let dir_err = 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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(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/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::PermissionDeniedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#PermissionDenied#, "access denied");
191 let load_err = LoadErrorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#::DirectoryReadrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead# {
192 pathrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead#path.: PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/test/dir"),
193 errorrust-analyzer cargo apt-sources 0.3.0 error/LoadError#DirectoryRead#error.: dir_err,
194 };
195 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(load_err
196 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
197 .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("Failed to read directory /test/dir"));
198 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(load_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("access denied"));
199 }
200 }