web, api: terminate request on parse error
When a parser error occurs, the request is not terminated which causes the HTML page to be dumped after the error message.
This commit is contained in:
parent
1526372946
commit
3f6bdee18d
1
api.go
1
api.go
|
@ -25,6 +25,7 @@ func CreateApiHandler(settings *TranslateSettings) func(w http.ResponseWriter, r
|
|||
translation, err := Translate(settings, from, to, text)
|
||||
if err != nil {
|
||||
writeError(w, 500, err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(translation))
|
||||
|
|
1
web.go
1
web.go
|
@ -27,6 +27,7 @@ func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func
|
|||
translation, err := Translate(settings, from, to, text)
|
||||
if err != nil {
|
||||
writeError(w, 500, err)
|
||||
return
|
||||
}
|
||||
|
||||
tmpl.ExecuteTemplate(w, "index", indexPageData{Languages, from, to, text, translation})
|
||||
|
|
Loading…
Reference in New Issue