OSDN Git Service

use multi-catch
authorOlyutorskii <olyutorskii@users.osdn.me>
Mon, 28 May 2018 15:12:55 +0000 (00:12 +0900)
committerOlyutorskii <olyutorskii@users.osdn.me>
Mon, 28 May 2018 15:12:55 +0000 (00:12 +0900)
src/main/java/jp/sfjp/jindolf/Controller.java
src/main/java/jp/sfjp/jindolf/config/ConfigFile.java
src/main/java/jp/sfjp/jindolf/config/InterVMLock.java
src/main/java/jp/sfjp/jindolf/data/Avatar.java
src/main/java/jp/sfjp/jindolf/data/LandsModel.java
src/main/java/jp/sfjp/jindolf/log/LoggingDispatcher.java
src/main/java/jp/sfjp/jindolf/summary/GameSummary.java

index 6693a62..ac8e994 100644 (file)
@@ -547,15 +547,10 @@ public class Controller
         final LookAndFeel lnf;
         try{
             lnf = (LookAndFeel) ( lnfClass.newInstance() );
-        }catch(InstantiationException e){
-            String warnMsg = MessageFormat.format(ERRFORM_LAF, className);
-            warnDialog(ERRTITLE_LAF, warnMsg, e);
-            return;
-        }catch(IllegalAccessException e){
-            String warnMsg = MessageFormat.format(ERRFORM_LAF, className);
-            warnDialog(ERRTITLE_LAF, warnMsg, e);
-            return;
-        }catch(ClassCastException e){
+        }catch(   InstantiationException
+                | IllegalAccessException
+                | ClassCastException
+                e){
             String warnMsg = MessageFormat.format(ERRFORM_LAF, className);
             warnDialog(ERRTITLE_LAF, warnMsg, e);
             return;
@@ -1291,10 +1286,7 @@ public class Controller
                             return;
                         }
                     });
-                }catch(InvocationTargetException e){
-                    LOGGER.log(Level.SEVERE,
-                            "タブ操作で致命的な障害が発生しました", e);
-                }catch(InterruptedException e){
+                }catch(InvocationTargetException | InterruptedException e){
                     LOGGER.log(Level.SEVERE,
                             "タブ操作で致命的な障害が発生しました", e);
                 }
@@ -1314,11 +1306,9 @@ public class Controller
                                 return;
                             }
                         });
-                    }catch(InvocationTargetException e){
-                        LOGGER.log(Level.SEVERE,
-                                "ブラウザ表示で致命的な障害が発生しました",
-                                e );
-                    }catch(InterruptedException e){
+                    }catch(   InvocationTargetException
+                            | InterruptedException
+                            e){
                         LOGGER.log(Level.SEVERE,
                                 "ブラウザ表示で致命的な障害が発生しました",
                                 e );
@@ -1726,9 +1716,7 @@ public class Controller
         }else{
             try{
                 SwingUtilities.invokeAndWait(microJob);
-            }catch(InvocationTargetException e){
-                LOGGER.log(Level.SEVERE, "ビジー処理で失敗", e);
-            }catch(InterruptedException e){
+            }catch(InvocationTargetException | InterruptedException e){
                 LOGGER.log(Level.SEVERE, "ビジー処理で失敗", e);
             }
         }
index 81cb447..fe92f87 100644 (file)
@@ -399,9 +399,7 @@ public final class ConfigFile{
                     "コピーすれば、そちらの設定が優先して使われます。");
             writer.println(
                     "「lock」の名前を持つファイルはロックファイルです。");
-        }catch(IOException e){
-            abortCantWrite(file);
-        }catch(SecurityException e){
+        }catch(IOException | SecurityException e){
             abortCantWrite(file);
         }finally{
             if(writer != null){
index 383d39b..964225f 100644 (file)
@@ -210,9 +210,7 @@ public class InterVMLock{
             boolean created = false;
             try{
                 created = this.lockFile.createNewFile();
-            }catch(IOException e){
-                assert true;   // IGNORE
-            }catch(SecurityException e){
+            }catch(IOException | SecurityException e){
                 assert true;   // IGNORE
             }finally{
                 if(created){
index ffe904a..4925e09 100644 (file)
@@ -41,13 +41,11 @@ public class Avatar implements Comparable<Avatar> {
         try{
             DocumentBuilder builder = XmlUtils.createDocumentBuilder();
             predefs = PreDefAvatar.buildPreDefAvatarList(builder);
-        }catch(IOException e){
-            throw new ExceptionInInitializerError(e);
-        }catch(ParserConfigurationException e){
-            throw new ExceptionInInitializerError(e);
-        }catch(SAXException e){
-            throw new ExceptionInInitializerError(e);
-        }catch(URISyntaxException e){
+        }catch(   IOException
+                | ParserConfigurationException
+                | SAXException
+                | URISyntaxException
+                e){
             throw new ExceptionInInitializerError(e);
         }
 
index 9a3805d..7804e03 100644 (file)
@@ -99,16 +99,11 @@ public class LandsModel implements TreeModel{ // ComboBoxModelも付けるか?
         try{
             DocumentBuilder builder = XmlUtils.createDocumentBuilder();
             landDefList = LandDef.buildLandDefList(builder);
-        }catch(IOException e){
-            LOGGER.log(Level.SEVERE, "failed to load land list", e);
-            return;
-        }catch(SAXException e){
-            LOGGER.log(Level.SEVERE, "failed to load land list", e);
-            return;
-        }catch(URISyntaxException e){
-            LOGGER.log(Level.SEVERE, "failed to load land list", e);
-            return;
-        }catch(ParserConfigurationException e){
+        }catch(   IOException
+                | SAXException
+                | URISyntaxException
+                | ParserConfigurationException
+                e){
             LOGGER.log(Level.SEVERE, "failed to load land list", e);
             return;
         }
index 710c195..6c73628 100644 (file)
@@ -64,14 +64,11 @@ public class LoggingDispatcher extends EventQueue{
     protected void dispatchEvent(AWTEvent event){
         try{
             super.dispatchEvent(event);
-        }catch(RuntimeException e){
+        }catch(RuntimeException | Error e){
             logThrowable(e);
             throw e;
         }catch(Exception e){
             logThrowable(e);
-        }catch(Error e){
-            logThrowable(e);
-            throw e;
         }
         // TODO Toolkit#beep()もするべきか
         // TODO モーダルダイアログを出すべきか
index dc5f5d7..299afdc 100644 (file)
@@ -708,9 +708,7 @@ public class GameSummary{
                 URL url = new URL(urlText);
                 URI uri = url.toURI();
                 urlText = uri.toASCIIString();
-            }catch(MalformedURLException e){
-                // NOTHING
-            }catch(URISyntaxException e){
+            }catch(MalformedURLException | URISyntaxException e){
                 // NOTHING
             }
             // PukiWikiではURL内の&のエスケープは不要?