Skip to content
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

Only chain on 404 errors, log and return others as 500 #802

Merged
merged 2 commits into from
Jun 3, 2020

Conversation

Nemo157
Copy link
Member

@Nemo157 Nemo157 commented Jun 2, 2020

Results in logs like

web_1  | 2020/06/02 08:13:07 [ERROR] cratesfyi::web: internal server error: Error rendering "releases_feed" line 10, col 10: Helper not defined: "content"

and a page like

image

when I reapply the bug in #728

Fixes #801

src/web/mod.rs Outdated
} else {
Err(e)
}
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions on ways to rewrite this would be appreciated, seems like it needs some sort of conditional or_else_if(|e| e.response.status == Some(status::NotFound), |e| self.router_handler.handle(req)).

Copy link
Member

@jyn514 jyn514 Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a helper handle_if_404 closure would be nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

let handle_if_404 = |e, handler| if e.response.status == Some(status::NotFound) {
    handler(req)
} else {
    Err(e)
};

@Nemo157 Nemo157 force-pushed the chain-404 branch 2 times, most recently from 7775b99 to 438b9e9 Compare June 2, 2020 08:41
Page::new("internal server error".to_owned())
.set_status(status::InternalServerError)
.title("Internal server error")
.to_resp("error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to link to the GitHub page so people can make an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good followup issue to do once the template changes are in, all the error pages could do with a bit of a sprucing up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think asking to open an issue on GitHub this way is much beneficial for us: without a backtrace it's hard to then debug those issues.

A thing we could do is generate a random UUID, print it in the same line as the error and show it in the error page, so when people open the issue we can simply do a journalctl -u docs.rs | grep UUID to get the exact error the user encountered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UUID sounds useful but it can go in a follow-up, for now I want to get the bug fix in.

src/web/mod.rs Outdated
} else {
Err(e)
}
})
Copy link
Member

@jyn514 jyn514 Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a helper handle_if_404 closure would be nice.

Page::new("internal server error".to_owned())
.set_status(status::InternalServerError)
.title("Internal server error")
.to_resp("error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UUID sounds useful but it can go in a follow-up, for now I want to get the bug fix in.

@jyn514 jyn514 merged commit 14eecac into rust-lang:master Jun 3, 2020
@Nemo157 Nemo157 deleted the chain-404 branch June 3, 2020 15:28
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 this pull request may close these issues.

docs.rs reports 404s for internal server errors
3 participants