Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-25 12:36:28 +0000
committerLars Vogel2019-06-25 12:39:30 +0000
commit3120e75911309c7bb3e146d6ca2fa50ae6294ae0 (patch)
tree15ef10577a323fb08fe1beba2d65d34c517e16f2
parent1e37f40f05ae86bb56fb1b98dc8f928d28e239d8 (diff)
downloadeclipse.platform.swt-3120e75911309c7bb3e146d6ca2fa50ae6294ae0.tar.gz
eclipse.platform.swt-3120e75911309c7bb3e146d6ca2fa50ae6294ae0.tar.xz
eclipse.platform.swt-3120e75911309c7bb3e146d6ca2fa50ae6294ae0.zip
Using multi-catch
Change-Id: I3e6d10b933a4008797bd3d18efe7ce5cb98e16d9 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java5
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java2
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java35
3 files changed, 8 insertions, 34 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java
index 44c5f3ea10..a2488a1871 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java
@@ -66,10 +66,7 @@ public class SessionManagerDBus {
public void install() {
try {
Runtime.getRuntime().addShutdownHook(this);
- } catch (IllegalArgumentException ex) {
- // Shouldn't happen
- ex.printStackTrace();
- } catch (IllegalStateException ex) {
+ } catch (IllegalArgumentException | IllegalStateException ex) {
// Shouldn't happen
ex.printStackTrace();
} catch (SecurityException ex) {
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java
index a5fbf9d039..41925732e5 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java
@@ -1365,8 +1365,6 @@ public class FileViewer {
FileWriter out = new FileWriter(newFile);){
int count;
while ((count = in.read()) != -1) out.write(count);
- } catch (FileNotFoundException e) {
- return false;
} catch (IOException e) {
return false;
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java
index 39b4c08b44..4e3b0fb783 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/imageanalyzer/ImageAnalyzer.java
@@ -808,11 +808,7 @@ public class ImageAnalyzer {
// Display the image.
imageDataIndex = 0;
displayImage(imageData);
- } catch (SWTException e) {
- showErrorDialog(bundle.getString("Loading_lc"), filename, e);
- } catch (SWTError e) {
- showErrorDialog(bundle.getString("Loading_lc"), filename, e);
- } catch (OutOfMemoryError e) {
+ } catch (SWTException | SWTError | OutOfMemoryError e) {
showErrorDialog(bundle.getString("Loading_lc"), filename, e);
} finally {
shell.setCursor(null);
@@ -864,13 +860,7 @@ public class ImageAnalyzer {
imageDataIndex = 0;
displayImage(imageDataArray[imageDataIndex]);
}
- } catch (SWTException e) {
- showErrorDialog(bundle.getString("Loading_lc"), filename, e);
- loader = oldLoader;
- } catch (SWTError e) {
- showErrorDialog(bundle.getString("Loading_lc"), filename, e);
- loader = oldLoader;
- } catch (OutOfMemoryError e) {
+ } catch (SWTException | SWTError | OutOfMemoryError e) {
showErrorDialog(bundle.getString("Loading_lc"), filename, e);
loader = oldLoader;
} finally {
@@ -921,10 +911,7 @@ public class ImageAnalyzer {
imageDataIndex = 0;
displayImage(imageDataArray[imageDataIndex]);
}
- } catch (Exception e) {
- showErrorDialog(bundle.getString("Loading_lc"), urlname, e);
- loader = oldLoader;
- } catch (OutOfMemoryError e) {
+ } catch (Exception | OutOfMemoryError e) {
showErrorDialog(bundle.getString("Loading_lc"), urlname, e);
loader = oldLoader;
} finally {
@@ -1007,9 +994,7 @@ public class ImageAnalyzer {
if (imageData.type == SWT.IMAGE_JPEG) loader.compression = compressionCombo.indexOf(compressionCombo.getText()) + 1;
if (imageData.type == SWT.IMAGE_PNG) loader.compression = compressionCombo.indexOf(compressionCombo.getText());
loader.save(fileName, imageData.type);
- } catch (SWTException e) {
- showErrorDialog(bundle.getString("Saving_lc"), fileName, e);
- } catch (SWTError e) {
+ } catch (SWTException | SWTError e) {
showErrorDialog(bundle.getString("Saving_lc"), fileName, e);
} finally {
shell.setCursor(null);
@@ -1117,9 +1102,7 @@ public class ImageAnalyzer {
shell.setText(createMsg(bundle.getString("Analyzer_on"), filename));
typeLabel.setText(createMsg(bundle.getString("Type_string"), fileTypeString(filetype)));
- } catch (SWTException e) {
- showErrorDialog(bundle.getString("Saving_lc"), filename, e);
- } catch (SWTError e) {
+ } catch (SWTException | SWTError e) {
showErrorDialog(bundle.getString("Saving_lc"), filename, e);
} finally {
shell.setCursor(null);
@@ -1175,9 +1158,7 @@ public class ImageAnalyzer {
loader.data = new ImageData[] {maskImageData};
loader.save(filename, filetype);
- } catch (SWTException e) {
- showErrorDialog(bundle.getString("Saving_lc"), filename, e);
- } catch (SWTError e) {
+ } catch (SWTException | SWTError e) {
showErrorDialog(bundle.getString("Saving_lc"), filename, e);
} finally {
shell.setCursor(null);
@@ -1259,9 +1240,7 @@ public class ImageAnalyzer {
imageDataIndex = 0;
displayImage(newImageData[imageDataIndex]);
- } catch (Exception e) {
- showErrorDialog(bundle.getString("Reloading_lc"), currentName, e);
- } catch (OutOfMemoryError e) {
+ } catch (Exception | OutOfMemoryError e) {
showErrorDialog(bundle.getString("Reloading_lc"), currentName, e);
} finally {
shell.setCursor(null);

Back to the top