Add pygments error handling

This commit is contained in:
Eliot Whalan 2016-06-23 09:55:08 +10:00
parent cd6db3eaa6
commit c927198df3
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 5 additions and 1 deletions

View File

@ -185,7 +185,11 @@ func langHandler(w http.ResponseWriter, r *http.Request) {
paste := vars["pasteId"] paste := vars["pasteId"]
lang := vars["lang"] lang := vars["lang"]
s := getPaste(paste) s := getPaste(paste)
highlight := pygments.Highlight(html.UnescapeString(s), html.EscapeString(lang), "html", "full, style=autumn,linenos=True, lineanchors=True,anchorlinenos=True,", "utf-8") highlight, err := pygments.Highlight(html.UnescapeString(s), html.EscapeString(lang), "html", "full, style=autumn,linenos=True, lineanchors=True,anchorlinenos=True,", "utf-8")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
io.WriteString(w, highlight) io.WriteString(w, highlight)
} }