fix: _to_json interprets "error" key incorrectly

"error" in JSON keys does not imply APIerror,
but instead it may contain a message caused by a
failure with C source code compilation (testrunner), for example.