| Summary: | [12][surround with try/catch] results in error with switch expression | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Noopur Gupta <noopur_gupta> |
| Component: | UI | Assignee: | Kalyan Prasad Tatavarthi <kalyan_prasad> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 4.11 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: |
https://git.eclipse.org/r/142244 https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d55c08dcfcdc1388c0571f8510369d5a45be1227 |
||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 545120 | ||
Not only in this case but surrounding a Throw statement with a try-catch statement is not correct. This proposal should not even be shown if the error is on a Throw Statement. New Gerrit change created: https://git.eclipse.org/r/142244 Gerrit change https://git.eclipse.org/r/142244 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d55c08dcfcdc1388c0571f8510369d5a45be1227 |
void throwing (int i) { int next = switch (i) { case 1 -> 2; default -> throw new Exception(); }; } - Apply "surround with try/catch" proposal on the error. It results in: void throwing (int i) { int next = switch (i) { case 1 -> 2; default -> try { throw new Exception(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }; } This gives an error (as mentioned in bug 545118). It should be checked how to represent a try-catch in a case statement. If it is not possible to represent it then the proposal should not be shown.