Skip to content

errors/2 advices - #94

Merged
JosteinGj merged 1 commit into
mainfrom
errors/2-advices
Sep 16, 2026
Merged

JosteinGj merged 1 commit into
mainfrom
errors/2-advices

Conversation

@JosteinGj

Copy link
Copy Markdown
Contributor

What this changes

How it was verified

Checklist

  • Pull requests this one depends on are named above and merged first, or there are none
  • Commits are signed off (git commit -s), per CONTRIBUTING.md
  • ./gradlew build passes
  • Behaviour visible outside this repo is reflected in the documentation, or does not need to be
    (see AGENTS.md for which of the two documentation sites it belongs in)

@JosteinGj
JosteinGj added this pull request to stack #99 September 15, 2026 09:17
@JosteinGj
JosteinGj marked this pull request as ready for review September 16, 2026 07:50
@JosteinGj
JosteinGj requested a review from olavgg as a code owner September 16, 2026 07:50
Base automatically changed from errors/1-problems-helper to main September 16, 2026 07:50
Converts the two wrapper-shaped advices and adds the three that were missing.
Controllers still catch most of these locally, so their bodies are unchanged
until the next commit removes those catches.

BadRequestExceptionHandler and ConcurrencyExceptionHandler now return
ProblemDetail. The former's javadoc argued against exactly this, and the
argument was sound as stated: controllers catch BadRequestException locally and
return the wrapper, so converting the advice alone gives one exception two
shapes. That is an argument against changing it in isolation, not against the
shape — the local catches go in the same change.

ConflictError.cause = "concurrency" becomes the type .../errors/optimistic-lock.
It existed so clients could discriminate without string-matching the message,
which is what RFC 9457's type member is for.

Three new advices. ConstraintViolationException had none, so seventeen
controllers caught it themselves — twenty-six blocks calling BuildErrorResponse,
which returns a DataWrapper: a success-shaped envelope used as an error body.
DuplicateDataException had none, so fourteen controllers read the status out of
the payload with HttpStatusCode.valueOf(error.getCode()). MethodArgumentNotValid
had none, which is why adding @Valid to the thirty-six unvalidated bodies was
held: without a handler it would have introduced a fourth shape rather than
removing shapes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: jgjesdal <jostein@intellistream.ai>
@JosteinGj
JosteinGj merged commit f8a06e0 into main Sep 16, 2026
9 checks passed
@JosteinGj
JosteinGj deleted the errors/2-advices branch September 16, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants