mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
We were trying to write an error to a ResponseWriter After attempting to write to it, and this produces messages about superfluous WriteHeaders, which is correct. This patch changes things so that we report messages more clearly and verbosely if we hit them before writing, and if we try to write and fail, we log the message because that's all we can do. This does change semantics slightly, in that now we're marshalling separately from trying to write the marshalled data. I think this is probably a reasonable call because it lets us get diagnostics about a hypothetical encoding problem, but in practice I don't think there should be any encoding problems. So my guess is the actual error will occur in that last line, and be logged to the server console instead of failing to write over HTTP. Also note that this changes some of the messages to include the underlying error they're complaining about. We also merge the create/find and index/field cases because only a couple of lines of code changed between four largeish functions, and we test some of the failure cases. We don't have test coverage on the "field isn't provided" type things because the mux won't actually route things there without them, so far as I know. |
||
|---|---|---|
| .. | ||
| client.go | ||
| client_test.go | ||
| error.go | ||
| handler.go | ||
| handler_internal_test.go | ||
| handler_test.go | ||
| translator.go | ||
| translator_test.go | ||