Browse code

integration/plugin: fix unhandled errors in tests (errchkjson)

integration/plugin/logging/cmd/discard/driver.go:84:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
json.NewEncoder(w).Encode(&res)
^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/02/08 20:53:57
Showing 1 changed files
... ...
@@ -81,5 +81,7 @@ func respond(err error, w io.Writer) {
81 81
 	if err != nil {
82 82
 		res.Err = err.Error()
83 83
 	}
84
-	json.NewEncoder(w).Encode(&res)
84
+	if err := json.NewEncoder(w).Encode(&res); err != nil {
85
+		panic("failed to encode response: " + err.Error())
86
+	}
85 87
 }