Rework error handling to use http.Error()