aboutsummaryrefslogtreecommitdiffstats
path: root/license-generator/src/response.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-11-11 02:11:36 +0100
committerTeddy Wing2018-11-11 02:11:36 +0100
commitedf6fceedd9b4169ceb63172c60733ef84d78951 (patch)
tree5ff59d7708ad13b68d8a211b10d283a5c9dd972c /license-generator/src/response.rs
parenta9f405988052a49ad3ebbe2a5b1f0db80036b2cd (diff)
downloaddome-key-web-edf6fceedd9b4169ceb63172c60733ef84d78951.tar.bz2
main(): Extract 500 errors to a function
Clean up the `main()` function by extracting all these similar lines to a function.
Diffstat (limited to 'license-generator/src/response.rs')
-rw-r--r--license-generator/src/response.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/license-generator/src/response.rs b/license-generator/src/response.rs
index 701bf1a..aec2d22 100644
--- a/license-generator/src/response.rs
+++ b/license-generator/src/response.rs
@@ -19,3 +19,15 @@ Allow: {}",
pub fn set_500<W: Write>(w: &mut W) -> Result<()> {
Ok(writeln!(w, "Status: 500")?)
}
+
+pub fn error_500<W: Write>(w: &mut W, error: Option<Error>) {
+ if let Some(error) = error {
+ error!("{}", error);
+ }
+
+ set_500(w).unwrap_or(());
+ write!(w, "Content-Type: text/plain
+
+500 Internal Server Error")
+ .unwrap_or(());
+}