Changeset 2246 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2009-10-04T14:43:54+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r2240 r2246 10 10 import java.net.URL; 11 11 import java.net.UnknownHostException; 12 import java.util.regex.Matcher; 13 import java.util.regex.Pattern; 12 14 13 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 14 17 import org.openstreetmap.josm.io.OsmApi; 15 18 import org.openstreetmap.josm.io.OsmApiException; … … 51 54 } 52 55 56 /** 57 * Explains a precondition exception when a child relation could not be deleted because 58 * it is still referred to by an undeleted parent relation. 59 * 60 * @param e the exception 61 * @param childRelation the child relation 62 * @param parentRelation the parent relation 63 * @return 64 */ 65 public static String explainDeletedRelationStillInUse(OsmApiException e, long childRelation, long parentRelation) { 66 String msg = tr( 67 "<html><strong>Failed</strong> to delete <strong>relation {0}</strong>." 68 + " It is still referred to by relation {1}.<br>" 69 + "Please load relation {1}, remove the reference to relation {0}, and upload again.</html>", 70 childRelation,parentRelation 71 ); 72 return msg; 73 } 53 74 54 75 /** … … 59 80 public static String explainPreconditionFailed(OsmApiException e) { 60 81 e.printStackTrace(); 61 String msg = tr( 82 String msg = e.getErrorHeader(); 83 if (msg != null) { 84 String pattern = "Precondition failed: The relation (\\d+) is used in relation (\\d+)\\."; 85 Pattern p = Pattern.compile(pattern); 86 Matcher m = p.matcher(msg); 87 if (m.matches()) { 88 long childRelation = Long.parseLong(m.group(1)); 89 long parentRelation = Long.parseLong(m.group(2)); 90 return explainDeletedRelationStillInUse(e, childRelation, parentRelation); 91 } 92 } 93 msg = tr( 62 94 "<html>Uploading to the server <strong>failed</strong> because your current<br>" 63 95 + "dataset violates a precondition.<br>" + "The error message is:<br>" + "{0}" + "</html>", e
Note:
See TracChangeset
for help on using the changeset viewer.