openrewrite / openrewrite/rewrite
Add source snippet to exception stack trace for easier debugging
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 571
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What problem are you trying to solve?
When a recipe throws an exception, only the file name of the source file is shown. Quite often that makes guessing the affected source snippet basically impossible, at least that's my experience from previous bug reports. Therefore adding either a short source snippet or the position in the file (line and row, or offset) would really help debugging recipe exceptions.
Describe the solution you'd like
In a prototype, I just added cursor.toString() to the log output that prints the exception stack trace. While that produced far too much output, it helped me identify the relevant source code in many cases, as this produces a kind of "nested snippets" with the uppermost being the relevant piece.
You surely have better ideas how to do that.
Are you interested in contributing this feature to OpenRewrite?
You probably can do that better than me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. Start by locating the logging that prints recipe exception stack traces and compare it with the reported cursor.toString() prototype; done means exceptions show a concise relevant source snippet or position without overwhelming nested output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100