diff options
author | Teddy Wing | 2018-11-11 02:11:36 +0100 |
---|---|---|
committer | Teddy Wing | 2018-11-11 02:11:36 +0100 |
commit | edf6fceedd9b4169ceb63172c60733ef84d78951 (patch) | |
tree | 5ff59d7708ad13b68d8a211b10d283a5c9dd972c /license-generator/src/response.rs | |
parent | a9f405988052a49ad3ebbe2a5b1f0db80036b2cd (diff) | |
download | dome-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.rs | 12 |
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(()); +} |