Changeset 8308 in josm for trunk/src/org/openstreetmap/josm/io/AbstractParser.java
- Timestamp:
- 2015-05-02T00:55:19+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/AbstractParser.java
r8148 r8308 25 25 */ 26 26 public abstract class AbstractParser extends DefaultHandler { 27 27 28 28 /** the current primitive to be read */ 29 29 protected HistoryOsmPrimitive currentPrimitive; … … 34 34 this.locator = locator; 35 35 } 36 36 37 37 protected abstract void throwException(String message) throws SAXException; 38 39 protected abstract void throwException(String message, Exception e) throws SAXException; 38 40 39 41 protected final long getMandatoryAttributeLong(Attributes attr, String name) throws SAXException { … … 46 48 l = Long.parseLong(v); 47 49 } catch(NumberFormatException e) { 48 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v) );50 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v), e); 49 51 } 50 52 if (l < 0) { … … 62 64 l = Long.parseLong(v); 63 65 } catch(NumberFormatException e) { 64 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v) );66 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v), e); 65 67 } 66 68 if (l < 0) { … … 79 81 d = Double.parseDouble(v); 80 82 } catch(NumberFormatException e) { 81 throwException(tr("Illegal value for attribute ''{0}'' of type double. Got ''{1}''.", name, v) );83 throwException(tr("Illegal value for attribute ''{0}'' of type double. Got ''{1}''.", name, v), e); 82 84 } 83 85 return d; … … 102 104 return false; // not reached 103 105 } 104 106 105 107 protected final HistoryOsmPrimitive createPrimitive(Attributes atts, OsmPrimitiveType type) throws SAXException { 106 108 long id = getMandatoryAttributeLong(atts,"id"); … … 152 154 currentPrimitive = createPrimitive(atts, OsmPrimitiveType.WAY); 153 155 } 154 156 155 157 protected final void startRelation(Attributes atts) throws SAXException { 156 158 currentPrimitive = createPrimitive(atts, OsmPrimitiveType.RELATION); … … 175 177 type = OsmPrimitiveType.fromApiTypeName(v); 176 178 } catch(IllegalArgumentException e) { 177 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type OsmPrimitiveType. Got ''{1}''.", "type", v) );179 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type OsmPrimitiveType. Got ''{1}''.", "type", v), e); 178 180 } 179 181 String role = getMandatoryAttributeString(atts, "role"); … … 181 183 ((HistoryRelation)currentPrimitive).addMember(member); 182 184 } 183 185 184 186 protected final boolean doStartElement(String qName, Attributes atts) throws SAXException { 185 187 switch (qName) {
Note:
See TracChangeset
for help on using the changeset viewer.