Changeset 13499 in josm
- Timestamp:
- 2018-03-04T16:09:51+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r12620 r13499 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 19 20 import org.openstreetmap.josm.io.ChangesetClosedException; 20 21 import org.openstreetmap.josm.io.IllegalDataException; … … 361 362 */ 362 363 public static void explainGenericHttpException(OsmApiException e) { 363 HelpAwareOptionPane.showOptionDialog( 364 Main.parent, 365 ExceptionUtil.explainGeneric(e), 364 String body = e.getErrorBody(); 365 Object msg = null; 366 if ("text/html".equals(e.getContentType()) && body != null && body.startsWith("<") && body.contains("<html>")) { 367 msg = new HtmlPanel(body); 368 } else { 369 msg = ExceptionUtil.explainGeneric(e); 370 } 371 HelpAwareOptionPane.showOptionDialog( 372 Main.parent, 373 msg, 366 374 tr("Communication with OSM server failed"), 367 375 JOptionPane.ERROR_MESSAGE, -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r13488 r13499 727 727 CredentialsManager.getInstance().purgeCredentialsCache(RequestorType.SERVER); 728 728 throw new OsmApiException(retCode, errorHeader, errorBody, activeConnection.getURL().toString(), 729 doAuthenticate ? retrieveBasicAuthorizationLogin(client) : null); 729 doAuthenticate ? retrieveBasicAuthorizationLogin(client) : null, response.getContentType()); 730 730 default: 731 731 throw new OsmApiException(retCode, errorHeader, errorBody); -
trunk/src/org/openstreetmap/josm/io/OsmApiException.java
r13493 r13499 12 12 13 13 private int responseCode; 14 private String contentType; 14 15 private String errorHeader; 15 16 private String errorBody; … … 25 26 * @param accessedUrl The complete URL accessed when this error occured 26 27 * @param login the login used to connect to OSM API (can be null) 27 * @since 12992 28 */ 29 public OsmApiException(int responseCode, String errorHeader, String errorBody, String accessedUrl, String login) { 28 * @param contentType the response content-type 29 * @since 13499 30 */ 31 public OsmApiException(int responseCode, String errorHeader, String errorBody, String accessedUrl, String login, String contentType) { 30 32 this.responseCode = responseCode; 31 33 this.errorHeader = errorHeader; … … 33 35 this.accessedUrl = accessedUrl; 34 36 this.login = login; 37 this.contentType = contentType; 38 } 39 40 /** 41 * Constructs an {@code OsmApiException} with the specified response code, error header and error body 42 * @param responseCode The HTTP response code replied by the OSM server. 43 * See {@link java.net.HttpURLConnection HttpURLConnection} for predefined HTTP response code values 44 * @param errorHeader The error header, as transmitted in the {@code Error} field of the HTTP response header 45 * @param errorBody The error body, as transmitted in the HTTP response body 46 * @param accessedUrl The complete URL accessed when this error occured 47 * @param login the login used to connect to OSM API (can be null) 48 * @since 12992 49 */ 50 public OsmApiException(int responseCode, String errorHeader, String errorBody, String accessedUrl, String login) { 51 this(responseCode, errorHeader, errorBody, accessedUrl, login, null); 35 52 } 36 53 … … 233 250 return login; 234 251 } 252 253 /** 254 * Sets the response content-type. 255 * @param contentType the response content-type. 256 * @since 13499 257 */ 258 public final void setContentType(String contentType) { 259 this.contentType = contentType; 260 } 261 262 /** 263 * Replies the response content-type. 264 * @return the response content-type 265 * @since 13499 266 */ 267 public final String getContentType() { 268 return contentType; 269 } 235 270 } -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r13356 r13499 208 208 String errorHeader = response.getHeaderField("Error"); 209 209 String errorBody = fetchResponseText(response); 210 throw new OsmApiException(response.getResponseCode(), errorHeader, errorBody, url.toString()); 210 throw new OsmApiException(response.getResponseCode(), errorHeader, errorBody, url.toString(), null, 211 response.getContentType()); 211 212 } 212 213
Note:
See TracChangeset
for help on using the changeset viewer.