Skip to content

Fix panic on ctry! error #858

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

Merged
merged 1 commit into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ r2d2_postgres = "0.14"
# url@2 for other usecases
url = { version = "2.1.1", features = ["serde"] }
badge = { path = "src/web/badge" }
backtrace = "0.3"
failure = "0.1.3"
comrak = { version = "0.3", default-features = false }
toml = "0.5"
Expand Down
17 changes: 11 additions & 6 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ macro_rules! ctry {
match $result {
Ok(v) => v,
Err(e) => {
return $crate::web::page::Page::new(format!("{:?}", e))
.title("An error has occured")
log::error!("{}\n{:?}", e, backtrace::Backtrace::new());
return $crate::web::page::Page::new(format!("{}", e))
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure the user should get the raw error?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see why not, usually it's something like 'File not found' which seems pretty harmless.

.title("Internal Server Error")
.set_status(::iron::status::BadRequest)
.to_resp("resp");
.to_resp("error");
}
}
};
Expand All @@ -27,10 +28,14 @@ macro_rules! cexpect {
match $option {
Some(v) => v,
None => {
return $crate::web::page::Page::new("Resource not found".to_owned())
.title("An error has occured")
log::error!(
"called cexpect!() on a `None` value\n{:?}",
backtrace::Backtrace::new()
);
return $crate::web::page::Page::new("Internal Server Error".to_owned())
.title("Internal Server Error")
.set_status(::iron::status::BadRequest)
.to_resp("resp");
.to_resp("error");
}
}
};
Expand Down
1 change: 1 addition & 0 deletions templates/error.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{{> header}}
{{content}}
{{> footer}}