Skip to content

docs.rs reports 404s for internal server errors #801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jyn514 opened this issue Jun 2, 2020 · 2 comments · Fixed by #802
Closed

docs.rs reports 404s for internal server errors #801

jyn514 opened this issue Jun 2, 2020 · 2 comments · Fixed by #802

Comments

@jyn514
Copy link
Member

jyn514 commented Jun 2, 2020

Originally found in #784.

If we encounter an error in impl Handler for CratesfyiHandler, we always return the first error even if it was a 404, ignoring all future errors. This hides panics/errors and makes things very hard to debug (I have a suspicion #800 is because of an internal error being hidden by this bug).

Relevant code:

fn handle(&self, req: &mut Request) -> IronResult<Response> {

@Kixiron
Copy link
Member

Kixiron commented Jun 2, 2020

Something that could help with identifying more errors would be adding log::error!("called ctry on an Err value: {} {}:{}", file!(), line!(), column!()) to these three macros, then we'd at least have a log of invocation locations and specific errors (where applicable)

docs.rs/src/web/mod.rs

Lines 9 to 44 in 9bd032f

macro_rules! ctry {
($result:expr) => {
match $result {
Ok(v) => v,
Err(e) => {
return $crate::web::page::Page::new(format!("{:?}", e))
.title("An error has occured")
.set_status(::iron::status::BadRequest)
.to_resp("resp");
}
}
};
}
/// cexpect will check an option and if it's not Some
/// it will return an error page response
macro_rules! cexpect {
($option:expr) => {
match $option {
Some(v) => v,
None => {
return $crate::web::page::Page::new("Resource not found".to_owned())
.title("An error has occured")
.set_status(::iron::status::BadRequest)
.to_resp("resp");
}
}
};
}
/// Gets an extension from Request
macro_rules! extension {
($req:expr, $ext:ty) => {
cexpect!($req.extensions.get::<$ext>())
};
}

@jyn514
Copy link
Member Author

jyn514 commented Jun 2, 2020

That helps with debugging, but still returns a 404 incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants