Skip to content

Commit 7f75260

Browse files
Merge pull request #331 from QuietMisdreavus/log-cleaning
clean up debug logging around "not found" errors
2 parents 54fff31 + af8c009 commit 7f75260

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

src/web/mod.rs

+20-23
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ impl Handler for CratesfyiHandler {
229229
self.static_handler.handle(req).or(Err(e))
230230
})
231231
.or_else(|e| {
232-
debug!("{}", e.description());
233232
let err = if let Some(err) = e.error.downcast::<error::Nope>() {
234233
*err
235234
} else if e.error.downcast::<NoRoute>().is_some() {
@@ -238,33 +237,31 @@ impl Handler for CratesfyiHandler {
238237
panic!("all cratesfyi errors should be of type Nope");
239238
};
240239

241-
match err {
242-
error::Nope::ResourceNotFound => {
243-
// print the path of the URL that triggered a 404 error
244-
struct DebugPath<'a>(&'a iron::Url);
245-
impl<'a> fmt::Display for DebugPath<'a> {
246-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
247-
for path_elem in self.0.path() {
248-
write!(f, "/{}", path_elem)?;
249-
}
250-
251-
if let Some(query) = self.0.query() {
252-
write!(f, "?{}", query)?;
253-
}
254-
255-
if let Some(hash) = self.0.fragment() {
256-
write!(f, "#{}", hash)?;
257-
}
258-
259-
Ok(())
240+
if let error::Nope::ResourceNotFound = err {
241+
// print the path of the URL that triggered a 404 error
242+
struct DebugPath<'a>(&'a iron::Url);
243+
impl<'a> fmt::Display for DebugPath<'a> {
244+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
245+
for path_elem in self.0.path() {
246+
write!(f, "/{}", path_elem)?;
247+
}
248+
249+
if let Some(query) = self.0.query() {
250+
write!(f, "?{}", query)?;
251+
}
252+
253+
if let Some(hash) = self.0.fragment() {
254+
write!(f, "#{}", hash)?;
260255
}
261-
}
262256

263-
debug!("Path: {}", DebugPath(&req.url));
257+
Ok(())
258+
}
264259
}
265-
_ => {}
260+
261+
debug!("Path not found: {}", DebugPath(&req.url));
266262
}
267263

264+
268265
Self::chain(err).handle(req)
269266
})
270267
}

0 commit comments

Comments
 (0)