Skip to content

Conversation

jbh010204
Copy link

This pull request refactors the error message formatting logic in BadJpqlGrammarErrorListener to improve readability, maintainability, and robustness. The main changes involve switching from string concatenation to using a StringBuilder, introducing a helper method for line extraction, and refining how error messages are constructed for different types of exceptions.

Error message formatting improvements:

  • Refactored the formatMessage method to use a StringBuilder instead of string concatenation, making the code more efficient and easier to read.
  • Improved handling of error messages for NoViableAltException by extracting the relevant line from the query and inserting a marker at the offending character position, using the new getLineAt helper method.
  • Added the private static getLineAt method to safely retrieve the appropriate line from the query string, handling edge cases where the line number may be out of bounds.
  • Enhanced error message construction for InputMismatchException by clarifying the expected tokens in the output.
  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 25, 2025
@mp911de
Copy link
Member

mp911de commented Sep 26, 2025

to improve readability, maintainability

The new variant is less readable and it doesn't fix any problem therefore we want to keep the code as-is.

@mp911de mp911de closed this Sep 26, 2025
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants