aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index e5f7235..5882909 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,6 +8,11 @@ use std::io::Read;
use kipper::jenkins;
use kipper::pull_request::CommitRef;
+fn internal_server_error() -> rouille::Response {
+ rouille::Response::text("500 Internal Server Error")
+ .with_status_code(500)
+}
+
fn main() {
rouille::start_server("localhost:8000", move |request| {
router!(request,
@@ -20,9 +25,15 @@ fn main() {
Some(mut data) => {
try_or_400!(data.read_to_string(&mut body));
- let commit_ref = CommitRef::new(body.as_ref());
+ let commit_ref = match CommitRef::new(body.as_ref()) {
+ Ok(cr) => cr,
+ Err(_) => return internal_server_error(),
+ };
- jenkins::find_and_track_build_and_update_status(commit_ref);
+ match jenkins::find_and_track_build_and_update_status(commit_ref) {
+ Ok(_) => {},
+ Err(_) => return internal_server_error(),
+ };
rouille::Response::text("202 Accepted")
.with_status_code(202)