Skip to content

weird behavior of the Quick Fix; "Surround with try/catch" #2711

Description

@arithauth

[weird behavior of auto generate when generating try-catch]

Environment
  • Operating System: macOS 12.6(Monterey)
  • JDK version: java(TM) SE Runtime Environment (build 18.0.2.1+1-1)
  • Visual Studio Code version: 1.71.2 (Universal)
  • Java extension version: v1.11.0
Steps To Reproduce
<-- insert
try {

} catch (Exception e) {
    // TODO: handle exception
}
throw new Exception(); <-- use Quick Fix; "Surround with try/catch"
try {

} catch (Exception e) {
    // TODO: handle exception
}
try {
    throw new Exception(); <-- surrounded by Quick Fix
} catch (Exception e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
try {

} catch (Exception e) {
    // TODO: handle exception
}
Current Result

Even if this variable name "e1" were "e", it won't conflict any other variables.

Expected Result

Maybe (Exception e) is correct behavior.

Additional Informations

Metadata

Metadata

Assignees

Type

No type

Projects

Status
✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions