[TASK] Report the API error code and HTTP status on failed requests - #99
Merged
Merged
Conversation
The failure output so far consisted of the API's message alone. TER
answers every masked server-side exception with the same generic
message, so that line cannot tell two unrelated defects apart:
{"status": 500, "code": 1603956982,
"message": "An error occured on handling the request."}
The code identifies the branch that produced the response and is the
part that makes such a failure diagnosable, so report it next to the
HTTP status:
Reason: An error occured on handling the request.
(HTTP 500, code 1603956982)
The reason is now built by RequestService::createFailureReason(), which
is covered by unit tests. Codes that carry no information - absent,
empty, 0 or non-scalar - are left out, so a response without one only
gains the status.
The fallback for a body with no usable message changes wording from
"Unknown (Status 502)" to "Unknown (HTTP 502)", which keeps the suffix
identical across all three cases.
Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
CybotTM
force-pushed
the
feature/report-ter-error-code
branch
from
August 2, 2026 11:01
edc0cb1 to
674cdab
Compare
bmack
approved these changes
Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed request reports the API's message and nothing else. That message is not always specific enough to act on: TER answers every server-side exception it masks with the same generic text, so the console line looks identical for unrelated defects.
{"status": 500, "code": 1603956982, "message": "An error occured on handling the request."}The
codeidentifies which branch produced the response, and it is currently discarded. This PR reports it next to the HTTP status.Before / after
Same command, same response, against a stub returning the body above:
Before
After
Across the response shapes the API actually produces:
{"status":500,"code":1603956982,"message":"An error occured…"}An error occured…An error occured… (HTTP 500, code 1603956982){"message":"Extension key not found."}Extension key not found.Extension key not found. (HTTP 404)Unknown (Status 502)Unknown (HTTP 502)A response without a usable code only gains the status; the third row is a wording change, so that the suffix is the same in all three cases.
Why this matters in practice
In #98 the behaviour behind that generic line had to be reconstructed entirely from outside the tool — repeated calls against the production TER, comparing what the listing had stored afterwards. The cause turned out to be a masked exception in TER's
RouteHandler, which is precisely what code1603956982denotes. Printed on the first call, it would have pointed straight there.Details
The reason is built by
RequestService::createFailureReason(), which is unit tested. Codes that carry no information — absent, empty,0or non-scalar — are omitted.error_descriptionkeeps precedence overmessage.Verified with
composer tests:unit(63 tests, 179 assertions) andcomposer cs. The transcripts above are captured output, not illustrations.