[java] replace default catch block template (IDEA-161593)

`throw e` won't fix the compilation error, comment - is not really better than empty catch block.

GitOrigin-RevId: ea002c332900b032392e766f3dd13fe3258ad49c
This commit is contained in:
Anna Kozlova
2022-01-14 13:12:26 +01:00
committed by intellij-monorepo-bot
parent 12cce2b05b
commit 724ed16f6f
38 changed files with 41 additions and 41 deletions

View File

@@ -1 +1 @@
${EXCEPTION}.printStackTrace();
throw new RuntimeException(${EXCEPTION});

View File

@@ -19,7 +19,7 @@ class Client {
try {
a.acting(s);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
});
}

View File

@@ -7,7 +7,7 @@ class a {
g();
} catch (Error e) {
} catch (Exception e) {
<caret><selection>e.printStackTrace();</selection>
<caret><selection>throw new RuntimeException(e);</selection>
}
}
}

View File

@@ -10,7 +10,7 @@ class a {
g();
// comment after
} catch (Exception e) {
<caret><selection>e.printStackTrace();</selection>
<caret><selection>throw new RuntimeException(e);</selection>
}
}
}

View File

@@ -10,7 +10,7 @@ class Test {
foo();
} catch (MyException1 e) {
} catch (MyException2 e) {
<caret><selection>e.printStackTrace();</selection>
<caret><selection>throw new RuntimeException(e);</selection>
}
}
}

View File

@@ -9,7 +9,7 @@ class Test {
void m() {
try (MyResource r = new MyResource()) {
} catch (IOException e) {
<selection>e.printStackTrace();</selection>
<selection>throw new RuntimeException(e);</selection>
}
}
}

View File

@@ -13,7 +13,7 @@ class Test {
r.doSomething();
} catch (E1 ignore) {
} catch (E2 e) {
<selection>e.printStackTrace();</selection>
<selection>throw new RuntimeException(e);</selection>
}
}
}

View File

@@ -11,9 +11,9 @@ class Test {
void m() {
try (MyResource r = new MyResource()) {
} catch (E1 e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (E2 e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -12,9 +12,9 @@ class CatchExceptions {
try {
foo();
} catch (FileNotFoundException e) {
<selection>e.printStackTrace();</selection>
<selection><caret>throw new RuntimeException(e);</selection>
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -4,7 +4,7 @@ class Foo {
try {
System.out.println(s);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -4,7 +4,7 @@ class Foo {
try {
System.out.println(Integer.parseInt(s));
} catch (NumberFormatException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -15,7 +15,7 @@ class C {
} catch (IOException e) {
throw new RuntimeException();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
};
} catch( Exception e) {

View File

@@ -9,7 +9,7 @@ public class ExTest {
try {
a = new String[]{maybeThrow("")};
} catch (Ex e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println(a);
}

View File

@@ -8,7 +8,7 @@ class C {
try {
S = getString();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

View File

@@ -10,7 +10,7 @@ class C {
try {
in = new FileInputStream("");
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -6,7 +6,7 @@ class C {
try {
if(foo() && foo())
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

View File

@@ -9,7 +9,7 @@ public class ExTest {
try {
return ExTest.maybeThrow(t);
} catch (Ex e) {
<selection>e.printStackTrace();</selection>
<selection>throw new RuntimeException(e);</selection>
}
};
}

View File

@@ -9,7 +9,7 @@ public class ExTest {
try {
ExTest.maybeThrow(t);
} catch (Ex e) {
e.printStackTrace();
throw new RuntimeException(e);
}
};
}

View File

@@ -5,7 +5,7 @@ public class Test {
try {
foo = bar();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
foo.toString();
}

View File

@@ -4,7 +4,7 @@ class Test {
// This is comment"
int i = 1;
} catch (Exception e) {
<caret><selection>e.printStackTrace();</selection>
<caret><selection>throw new RuntimeException(e);</selection>
} finally {
}
}

View File

@@ -4,7 +4,7 @@ class Test {
// This is comment"
int i = 1;
} catch (Exception e) {
<caret><selection>e.printStackTrace();</selection>
<caret><selection>throw new RuntimeException(e);</selection>
}
}
}

View File

@@ -4,7 +4,7 @@ class Test {
try {
I i = ExceptionTest::foo;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

View File

@@ -4,7 +4,7 @@ class ModuleATest {
try {
foo();
} catch (final Smth ex1) {
ex1.printStackTrace();
throw new RuntimeException(ex1);
}
Exception ex1 = null;
}

View File

@@ -6,7 +6,7 @@ class C {
/*1*/
throw new /*2*/RuntimeException("a")/*3*/;/*4*/
} catch (RuntimeException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
default -> "";

View File

@@ -6,7 +6,7 @@ class C {
try {
yield "a" + "b";
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
}
}

View File

@@ -3,7 +3,7 @@ public class Foo {
try {
new Object()
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -3,7 +3,7 @@ public class Foo {
try {
Object obj = new Object()<caret>
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -3,7 +3,7 @@ public class Foo {
try {
doAct() + "aaa"
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

View File

@@ -3,7 +3,7 @@ public class Foo {
try {
doAct()
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
int i=0;

View File

@@ -5,7 +5,7 @@ public class Foo {
try {
doAct()<caret>
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

View File

@@ -3,7 +3,7 @@ public class Foo {
try {
doAct()
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

View File

@@ -6,7 +6,7 @@ class Test {
try {
foo();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -6,7 +6,7 @@ class Test {
try {
a = foo();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println(a);
}

View File

@@ -10,7 +10,7 @@ class ChangeSignatureTest {
try {
bar();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -10,7 +10,7 @@ class ChangeSignatureTest {
try {
bar();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -8,9 +8,9 @@ class High {
} catch (IllegalAccessException | InstantiationException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

View File

@@ -6,7 +6,7 @@ class AAA {
try {
System.out.println(System.in.read());
} c<caret>atch (IOException ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
}

View File

@@ -3,7 +3,7 @@ class Foo {
try {
new AddException().foo();
} catch (java.io.IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}