From c4a364be3c12886c99a3e5ea2e929c163afabc02 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Sun, 13 Nov 2016 18:43:24 -0200 Subject: [PATCH] Improve response output --- main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 93c94fa..a59d4bf 100644 --- a/main.go +++ b/main.go @@ -58,17 +58,18 @@ func handleSubmit(w http.ResponseWriter, r *http.Request, defaults []string) { out, err := exec.Command("spark-submit", args...).CombinedOutput() logDebug(string(out)) - if out != nil { - http.Error(w, string(out), 400) - return - } - if err != nil { - http.Error(w, err.Error(), 400) + msg := err.Error() + if out != nil { + msg = string(out) + } + + http.Error(w, msg, 400) return } w.WriteHeader(200) + w.Write(out) } func main() {