Changeset 7205 in josm for trunk/src/org
- Timestamp:
- 2014-06-01T15:00:00+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmApiException.java
r6087 r7205 36 36 */ 37 37 public OsmApiException(int responseCode, String errorHeader, String errorBody) { 38 this.responseCode = responseCode; 39 this.errorHeader = errorHeader; 40 this.errorBody = errorBody; 38 this(responseCode, errorHeader, errorBody, null); 41 39 } 42 40 -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r7187 r7205 47 47 * 48 48 * @param e the exception 49 * @return The HTML formatted error message to display 49 50 */ 50 51 public static String explainOsmApiInitializationException(OsmApiInitializationException e) { … … 57 58 58 59 59 /**60 * Creates the error message61 *62 * @param e the exception63 */64 60 public static String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) { 65 61 Main.error(e); … … 125 121 * 126 122 * @param e the exception 123 * @return The HTML formatted error message to display 127 124 */ 128 125 public static String explainPreconditionFailed(OsmApiException e) { … … 312 309 * 313 310 * @param e the exception 314 * @return the message311 * @return The HTML formatted error message to display 315 312 */ 316 313 public static String explainClientTimeout(OsmApiException e) { … … 327 324 * 328 325 * @param e the exception 329 * @return the message326 * @return The HTML formatted error message to display 330 327 */ 331 328 public static String explainGenericOsmApiException(OsmApiException e) { … … 354 351 * 355 352 * @param e the exception 353 * @return The HTML formatted error message to display 356 354 */ 357 355 public static String explainConflict(OsmApiException e) { … … 407 405 * 408 406 * @param e the exception 407 * @return The HTML formatted error message to display 409 408 */ 410 409 public static String explainChangesetClosedException(ChangesetClosedException e) { … … 423 422 * 424 423 * @param e the exception 424 * @return The HTML formatted error message to display 425 425 */ 426 426 public static String explainGeneric(Exception e) { … … 439 439 * 440 440 * @param e the exception 441 * /442 441 * @return The HTML formatted error message to display 442 */ 443 443 public static String explainSecurityException(OsmTransferException e) { 444 444 String apiUrl = e.getUrl(); … … 461 461 * 462 462 * @param e the exception 463 * @return The HTML formatted error message to display 463 464 */ 464 465 public static String explainNestedSocketException(OsmTransferException e) { … … 474 475 * 475 476 * @param e the exception 477 * @return The HTML formatted error message to display 476 478 */ 477 479 public static String explainNestedIOException(OsmTransferException e) { … … 489 491 * 490 492 * @param e the exception 493 * @return The HTML formatted error message to display 491 494 */ 492 495 public static String explainNestedIllegalDataException(OsmTransferException e) { … … 503 506 * 504 507 * @param e the exception 508 * @return The HTML formatted error message to display 505 509 */ 506 510 public static String explainInternalServerError(OsmTransferException e) { … … 511 515 512 516 /** 513 * Explains a {@link OsmApiException} which was thrown because of a bad 514 * request515 * 516 * @ param e the exception517 * Explains a {@link OsmApiException} which was thrown because of a bad request. 518 * 519 * @param e the exception 520 * @return The HTML formatted error message to display 517 521 */ 518 522 public static String explainBadRequest(OsmApiException e) { 519 String apiUrl = OsmApi.getOsmApi().getBaseUrl(); 520 String message = tr("The OSM server ''{0}'' reported a bad request.<br>", apiUrl); 521 if (e.getErrorHeader() != null && 522 (e.getErrorHeader().startsWith("The maximum bbox") || 523 e.getErrorHeader().startsWith("You requested too many nodes"))) { 523 String url = null; 524 if (e.getAccessedUrl() != null) { 525 try { 526 url = new URL(e.getAccessedUrl()).getHost(); 527 } catch (MalformedURLException e1) { 528 Main.warn(e1); 529 } 530 } 531 if (url == null && e.getUrl() != null) { 532 url = e.getUrl(); 533 } else if (url == null) { 534 url = OsmApi.getOsmApi().getBaseUrl(); 535 } 536 String message = tr("The OSM server ''{0}'' reported a bad request.<br>", url); 537 String errorHeader = e.getErrorHeader(); 538 if (errorHeader != null && (errorHeader.startsWith("The maximum bbox") || 539 errorHeader.startsWith("You requested too many nodes"))) { 524 540 message += "<br>" 525 541 + tr("The area you tried to download is too big or your request was too large." 526 542 + "<br>Either request a smaller area or use an export file provided by the OSM community."); 527 } else if (e .getErrorHeader()!= null) {528 message += tr("<br>Error message(untranslated): {0}", e .getErrorHeader());543 } else if (errorHeader != null) { 544 message += tr("<br>Error message(untranslated): {0}", errorHeader); 529 545 } 530 546 Main.error(e); … … 537 553 * 538 554 * @param e the exception 555 * @return The HTML formatted error message to display 539 556 */ 540 557 public static String explainBandwidthLimitExceeded(OsmApiException e) { … … 548 565 * 549 566 * @param e the exception 567 * @return The HTML formatted error message to display 550 568 */ 551 569 public static String explainNotFound(OsmApiException e) { … … 566 584 * 567 585 * @param e the exception 568 * /569 586 * @return The HTML formatted error message to display 587 */ 570 588 public static String explainNestedUnknownHostException(OsmTransferException e) { 571 589 String apiUrl = e.getUrl(); … … 609 627 * 610 628 * @param e the {@link OsmTransferException} 629 * @return The HTML formatted error message to display 611 630 */ 612 631 public static String explainOsmTransferException(OsmTransferException e) { … … 647 666 * 648 667 * @param e the exception 668 * @return The HTML formatted error message to display 649 669 */ 650 670 public static String explainGoneForUnknownPrimitive(OsmApiException e) { … … 662 682 * 663 683 * @param e the {@link Exception} 684 * @return The HTML formatted error message to display 664 685 */ 665 686 public static String explainException(Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.