Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: improve TextParser error handling#1061

Open
jpogorzelski wants to merge 1 commit intothymeleaf:3.1-masterfrom
jpogorzelski:feature/improve-text-parser-error-handling
Open

feat: improve TextParser error handling#1061
jpogorzelski wants to merge 1 commit intothymeleaf:3.1-masterfrom
jpogorzelski:feature/improve-text-parser-error-handling

Conversation

@jpogorzelski
Copy link

The purpose of this change in TextParser::parseDocument method is to catch TemplateProcessingException before fallback to generic Exception class in. TemplateProcessingException may contain line and column information in its fields, which is easy to access when handling parsing errors.

I stumbled upon this scenario, when building custom validator for end user defined templates in web based editor. In this case, it is important to have line and column where template has errors.
Currently, TextParser looses this information when catching generic Exception.

Currently, Thymeleaf contains 3 exception classes that maintain line and col information: TextParseException, RawParseException and TemplateProcessingException.
Another approach could be introducing custom exception class dedicated for containing line and col properties that could be inherited by those 3 mentioned above, but it would need bigger refactoring.

catch TemplateProcessingException that may contain line and column information before fallback to generic Exception
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.

1 participant