Ignore:
Timestamp:
2016-12-09T23:31:13+01:00 (7 years ago)
Author:
Don-vip
Message:

sonar - squid:S00112 - Generic exceptions should never be thrown: define JosmRuntimeException

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r11365 r11374  
    10301030                    l.rename((String) value);
    10311031                    break;
    1032                 default: throw new RuntimeException();
     1032                default:
     1033                    throw new IllegalArgumentException("Wrong column: " + col);
    10331034                }
    10341035                fireTableCellUpdated(row, col);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r11298 r11374  
    5555import org.openstreetmap.josm.tools.ImageProvider;
    5656import org.openstreetmap.josm.tools.InputMapUtils;
     57import org.openstreetmap.josm.tools.JosmRuntimeException;
    5758import org.openstreetmap.josm.tools.Shortcut;
    5859import org.xml.sax.SAXException;
     
    634635            } catch (InterruptedException | InvocationTargetException e) {
    635636                // FIXME: signature of realRun should have a generic checked exception we could throw here
    636                 throw new RuntimeException(e);
     637                throw new JosmRuntimeException(e);
    637638            } finally {
    638639                monitor.finishTask();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java

    r10965 r11374  
    3030import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.ToTagConvertable;
    3131import org.openstreetmap.josm.tools.CheckParameterUtil;
     32import org.openstreetmap.josm.tools.JosmRuntimeException;
    3233import org.openstreetmap.josm.tools.Utils;
    3334
     
    819820                return not ^ (Boolean) method.invoke(null, e);
    820821            } catch (IllegalAccessException | InvocationTargetException ex) {
    821                 throw new RuntimeException(ex);
     822                throw new JosmRuntimeException(ex);
    822823            }
    823824        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r11360 r11374  
    4040import org.openstreetmap.josm.tools.ColorHelper;
    4141import org.openstreetmap.josm.tools.Geometry;
     42import org.openstreetmap.josm.tools.JosmRuntimeException;
    4243import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
    4344import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     
    9798            parameterFunctions.add(Math.class.getMethod("tanh", double.class));
    9899        } catch (NoSuchMethodException | SecurityException ex) {
    99             throw new RuntimeException(ex);
     100            throw new JosmRuntimeException(ex);
    100101        }
    101102    }
     
    12401241                result = m.invoke(null, convertedArgs);
    12411242            } catch (IllegalAccessException | IllegalArgumentException ex) {
    1242                 throw new RuntimeException(ex);
     1243                throw new JosmRuntimeException(ex);
    12431244            } catch (InvocationTargetException ex) {
    12441245                Main.error(ex);
     
    13061307                result = m.invoke(null, convertedArgs);
    13071308            } catch (IllegalAccessException | IllegalArgumentException ex) {
    1308                 throw new RuntimeException(ex);
     1309                throw new JosmRuntimeException(ex);
    13091310            } catch (InvocationTargetException ex) {
    13101311                Main.error(ex);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r10837 r11374  
    4040import org.openstreetmap.josm.gui.mappaint.mapcss.Subpart;
    4141import org.openstreetmap.josm.tools.ColorHelper;
     42import org.openstreetmap.josm.tools.JosmRuntimeException;
    4243import org.openstreetmap.josm.tools.Pair;
    4344import org.openstreetmap.josm.tools.Utils;
     
    6667     */
    6768    public static enum LexicalState {
    68         PREPROCESSOR(0), /* the preprocessor */
    69         DEFAULT(2);      /* the main parser */
    70        
     69        /** the preprocessor */
     70        PREPROCESSOR(0),
     71        /** the main parser */
     72        DEFAULT(2);
     73
    7174        int idx; // the integer, which javacc assigns to this state
    72        
     75
    7376        LexicalState(int idx) {
    7477            if (!this.name().equals(MapCSSParserTokenManager.lexStateNames[idx])) {
    75                 throw new RuntimeException();
     78                throw new JosmRuntimeException("Wrong name for index " + idx);
    7679            }
    7780            this.idx = idx;
    7881        }
    79     };
     82    }
    8083   
    8184    /**
     
    9598            scs = new SimpleCharStream(in, encoding, 1, 1);
    9699        } catch (java.io.UnsupportedEncodingException e) {
    97             throw new RuntimeException(e);
     100            throw new JosmRuntimeException(e);
    98101        }
    99102        return new MapCSSParserTokenManager(scs, initState.idx);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r10837 r11374  
    6060import org.openstreetmap.josm.io.CachedFile;
    6161import org.openstreetmap.josm.tools.CheckParameterUtil;
     62import org.openstreetmap.josm.tools.JosmRuntimeException;
    6263import org.openstreetmap.josm.tools.LanguageInfo;
    6364import org.openstreetmap.josm.tools.Utils;
     
    108109                SUPPORTED_KEYS.add((String) f.get(null));
    109110                if (!f.getName().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(f.get(null))) {
    110                     throw new RuntimeException(f.getName());
     111                    throw new JosmRuntimeException(f.getName());
    111112                }
    112113            } catch (IllegalArgumentException | IllegalAccessException ex) {
    113                 throw new RuntimeException(ex);
     114                throw new JosmRuntimeException(ex);
    114115            }
    115116        }
     
    468469                        break;
    469470                    default:
    470                         final RuntimeException e = new RuntimeException(MessageFormat.format("Unknown MapCSS base selector {0}", base));
     471                        final RuntimeException e = new JosmRuntimeException(MessageFormat.format("Unknown MapCSS base selector {0}", base));
    471472                        Main.warn(tr("Failed to parse Mappaint styles from ''{0}''. Error was: {1}", url, e.getMessage()));
    472473                        Main.error(e);
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r11017 r11374  
    3737import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    3838import org.openstreetmap.josm.tools.GBC;
     39import org.openstreetmap.josm.tools.JosmRuntimeException;
    3940
    4041/**
     
    479480        // should have been set to Mercator at JOSM start.
    480481        if (pc == null)
    481             throw new RuntimeException("Couldn't find the current projection in the list of available projections!");
     482            throw new JosmRuntimeException("Couldn't find the current projection in the list of available projections!");
    482483
    483484        projectionCombo.addActionListener(e -> {
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagCellRenderer.java

    r10378 r11374  
    1212import javax.swing.border.EmptyBorder;
    1313import javax.swing.table.TableCellRenderer;
     14
     15import org.openstreetmap.josm.tools.JosmRuntimeException;
    1416
    1517/**
     
    102104        case 1: renderTagValue((TagModel) value); break;
    103105
    104         default: throw new RuntimeException("unexpected index in switch statement");
     106        default: throw new JosmRuntimeException("unexpected index in switch statement");
    105107        }
    106108        if (hasFocus && isSelected) {
Note: See TracChangeset for help on using the changeset viewer.