Changeset 4482 in josm


Ignore:
Timestamp:
2011-10-01T14:28:47+02:00 (13 years ago)
Author:
Don-vip
Message:

see #6821 - HTTP error 509 - "You have downloaded to much data" causes unhandled exception in HTML pane

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r4263 r4482  
    105105        msg = tr(
    106106                "<html>Uploading to the server <strong>failed</strong> because your current<br>"
    107                 + "dataset violates a precondition.<br>" + "The error message is:<br>" + "{0}" + "</html>", e
    108                 .getMessage().replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;"));
     107                + "dataset violates a precondition.<br>" + "The error message is:<br>" + "{0}" + "</html>",
     108                escapeReservedCharactersHTML(e.getMessage()));
    109109        return msg;
    110110    }
     
    298298        }
    299299        e.printStackTrace();
    300         return msg;
     300        return escapeReservedCharactersHTML(msg);
    301301    }
    302302
     
    410410        return message;
    411411    }
     412   
     413    /**
     414     * Explains a {@see OsmApiException} which was thrown because of
     415     * bandwidth limit exceeded (HTTP error 509)
     416     *
     417     * @param e the exception
     418     */
     419    public static String explainBandwidthLimitExceeded(OsmApiException e) {
     420        // TODO: Write a proper error message
     421        String message = explainGenericOsmApiException(e);
     422        e.printStackTrace();
     423        return message;
     424    }
     425   
    412426
    413427    /**
     
    504518            if (oae.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST)
    505519                return explainBadRequest(oae);
     520            if (oae.getResponseCode() == 509)
     521                return explainBandwidthLimitExceeded(oae);
    506522        }
    507523        return explainGeneric(e);
     
    522538                + "<br>"
    523539                + "The error message is:<br>" + "{0}"
    524                 + "</html>", e.getMessage().replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;"));
     540                + "</html>", escapeReservedCharactersHTML(e.getMessage()));
    525541        return msg;
    526542
     
    542558        return msg;
    543559    }
     560   
     561    /**
     562     * Replaces some HTML reserved characters (<, > and &) by their equivalent entity (&lt;, &gt; and &amp;);
     563     * @param s The unescaped string
     564     * @return The escaped string
     565     */
     566    public static String escapeReservedCharactersHTML(String s) {
     567        return s == null ? "" : s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
     568    }
    544569}
Note: See TracChangeset for help on using the changeset viewer.