Skip to content
This repository was archived by the owner on Jun 1, 2019. It is now read-only.

Commit c047bbe

Browse files
committed
Remove multi-catch
1 parent 02bfb9c commit c047bbe

File tree

7 files changed

+41
-8
lines changed

7 files changed

+41
-8
lines changed

src/com/google/javascript/jscomp/CheckRegExp.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public void visit(NodeTraversal t, Node n, Node parent) {
9393
? n.getLastChild().getString() : "";
9494
try {
9595
RegExpTree.parseRegExp(pattern, flags);
96-
} catch (IllegalArgumentException | IndexOutOfBoundsException ex) {
96+
} catch (IllegalArgumentException ex) {
97+
t.report(n, MALFORMED_REGEXP, ex.getMessage());
98+
} catch (IndexOutOfBoundsException ex) {
9799
t.report(n, MALFORMED_REGEXP, ex.getMessage());
98100
}
99101
}

src/com/google/javascript/jscomp/CompilerExecutor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ public T call() {
110110
} else {
111111
result = future.get();
112112
}
113-
} catch (InterruptedException | TimeoutException | ExecutionException e) {
113+
} catch (InterruptedException e) {
114+
throw new RuntimeException(e);
115+
} catch (TimeoutException e) {
116+
throw new RuntimeException(e);
117+
} catch (ExecutionException e) {
114118
throw new RuntimeException(e);
115119
}
116120
} else {

src/com/google/javascript/jscomp/ProcessClosurePrimitives.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,17 @@ private void processForwardDeclare(NodeTraversal t, Node n, Node parent) {
10891089
try {
10901090
typeDeclaration = Iterables.getOnlyElement(
10911091
convention.identifyTypeDeclarationCall(n));
1092-
} catch (NullPointerException | NoSuchElementException |
1093-
IllegalArgumentException e) {
1092+
} catch (NullPointerException e) {
1093+
compiler.report(
1094+
t.makeError(n, INVALID_FORWARD_DECLARE,
1095+
"A single type could not identified for the goog.forwardDeclare " +
1096+
"statement"));
1097+
} catch (NoSuchElementException e) {
1098+
compiler.report(
1099+
t.makeError(n, INVALID_FORWARD_DECLARE,
1100+
"A single type could not identified for the goog.forwardDeclare " +
1101+
"statement"));
1102+
} catch (IllegalArgumentException e) {
10941103
compiler.report(
10951104
t.makeError(n, INVALID_FORWARD_DECLARE,
10961105
"A single type could not identified for the goog.forwardDeclare " +

src/com/google/javascript/jscomp/SourceMapInput.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public SourceMapConsumerV3 getSourceMap() {
4848
parsedSourceMap = new SourceMapConsumerV3();
4949
try {
5050
parsedSourceMap.parse(sourceFile.getCode());
51-
} catch (IOException | SourceMapParseException parseFailure) {
51+
} catch (IOException parseFailure) {
52+
logger.log(
53+
Level.WARNING, "Failed to parse sourcemap", parseFailure);
54+
} catch (SourceMapParseException parseFailure) {
5255
logger.log(
5356
Level.WARNING, "Failed to parse sourcemap", parseFailure);
5457
}

src/com/google/javascript/jscomp/XtbMessageBundle.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ public XtbMessageBundle(InputStream xtb, @Nullable String projectId) {
8080
Handler contentHandler = new Handler();
8181
reader.setContentHandler(contentHandler);
8282
reader.parse(new InputSource(xtb));
83-
} catch (ParserConfigurationException | IOException | SAXException e) {
83+
} catch (ParserConfigurationException e) {
84+
throw new RuntimeException(e);
85+
} catch (IOException e) {
86+
throw new RuntimeException(e);
87+
} catch (SAXException e) {
8488
throw new RuntimeException(e);
8589
}
8690
}

src/com/google/javascript/jscomp/deps/TranspilingClosureBundler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,16 @@ public String call() {
132132
return compiler.toSource();
133133
}
134134
});
135-
} catch (ExecutionException | UncheckedExecutionException e) {
135+
} catch (ExecutionException e) {
136+
// IllegalStateExceptions thrown from the callable above will end up here as
137+
// UncheckedExecutionExceptions, per the contract of Cache#get. Throw the underlying
138+
// IllegalStateException so that the compiler error message is at the top of the stack trace.
139+
if (e.getCause() instanceof IllegalStateException) {
140+
throw (IllegalStateException) e.getCause();
141+
} else {
142+
throw Throwables.propagate(e);
143+
}
144+
} catch (UncheckedExecutionException e) {
136145
// IllegalStateExceptions thrown from the callable above will end up here as
137146
// UncheckedExecutionExceptions, per the contract of Cache#get. Throw the underlying
138147
// IllegalStateException so that the compiler error message is at the top of the stack trace.

src/com/google/javascript/jscomp/parsing/parser/Scanner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,9 @@ private String processUnicodeEscapes(String value) {
754754
}
755755
value = value.substring(0, escapeStart) + ch +
756756
value.substring(escapeEnd);
757-
} catch (NumberFormatException|StringIndexOutOfBoundsException e) {
757+
} catch (NumberFormatException e) {
758+
return null;
759+
} catch (StringIndexOutOfBoundsException e) {
758760
return null;
759761
}
760762
}

0 commit comments

Comments
 (0)