Skip to content

Harness Compilation error page has status 200 OK #198

@r32rf

Description

@r32rf

When Harness responds with a compilation error, it generates the page with 200 OK.
https://github.com/revel/cmd/blob/master/harness/harness.go#L137

atomic.CompareAndSwapInt32(&lastRequestHadError, 0, 1)
h.renderError(w, r, err)
return

It would probably be best to call w.WriteHeader(http.StatusInternalServerError).

This issue affected me in a AJAX handler that triggered the success callback on a compilation error with the HTML as a string rather than the decoded JSON object I was expecting.

Furthermore, it would be nicer if the error response also respected the Accept HTTP header. For example, if Accept equals "application/json":

{
    "Error": "Go Compilation Error", // Equal to the title of the html page.
    "Message": "The Go code %s does not compile: %s", // Equal to the content of .header p
    "File":  {
        "File": "%s (around line %d)", // Equal to .source h2
        "Line": "%s", // Equal to the highlighted code block rendered in .source
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions