- Timestamp:
- 2019-05-18T16:29:09+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r14810 r15084 286 286 msg = tr("Access to redacted version ''{0}'' of {1} {2} is forbidden.", 287 287 version, tr(type), id); 288 } else if (OsmApi.isUsingOAuth() ) {288 } else if (OsmApi.isUsingOAuth() && !ExceptionUtil.isUserBlocked(e)) { 289 289 msg = ExceptionUtil.explainFailedOAuthAuthorisation(e); 290 290 } else { -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r14326 r15084 14 14 import org.openstreetmap.josm.data.preferences.BooleanProperty; 15 15 import org.openstreetmap.josm.data.preferences.IntegerProperty; 16 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 16 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 17 18 import org.openstreetmap.josm.io.auth.CredentialsAgentException; … … 89 90 } 90 91 } catch (OsmTransferException e) { 91 Logging.warn(e);92 ExceptionDialogUtil.explainOsmTransferException(e); 92 93 } 93 94 } -
trunk/src/org/openstreetmap/josm/io/OsmApiException.java
r15077 r15084 213 213 public String getDisplayMessage() { 214 214 StringBuilder sb = new StringBuilder(); 215 if (errorHeader != null) { 216 sb.append(tr(errorHeader)); 217 sb.append(tr("(Code={0})", responseCode)); 218 } else if (errorBody != null && !errorBody.trim().isEmpty()) { 219 errorBody = errorBody.trim(); 220 sb.append(tr(errorBody)); 221 sb.append(tr("(Code={0})", responseCode)); 215 String header = Utils.strip(errorHeader); 216 String body = Utils.strip(errorBody); 217 if ((header == null || header.isEmpty()) && (body == null || body.isEmpty())) { 218 sb.append(tr("The server replied an error with code {0}.", responseCode)); 222 219 } else { 223 sb.append(tr("The server replied an error with code {0}.", responseCode)); 220 if (header != null && !header.isEmpty()) { 221 sb.append(tr(header)); 222 } 223 if (body != null && !body.isEmpty()) { 224 if (sb.length() > 0) { 225 sb.append(". "); 226 } 227 sb.append(tr(body)); 228 } 229 sb.append(' ').append(tr("(Code={0})", responseCode)); 224 230 } 225 231 return sb.toString(); -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r12992 r15084 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.I18n.trn; … … 43 44 public final class ExceptionUtil { 44 45 46 /** 47 * Error message sent by the OSM API when a user has been blocked. 48 */ 49 private static final String OSM_API_BLOCKED = 50 marktr("Your access to the API has been blocked. Please log-in to the web interface to find out more."); 51 45 52 private ExceptionUtil() { 46 53 // Hide default constructor for utils classes … … 296 303 public static String explainFailedAuthorisation(OsmApiException e) { 297 304 Logging.error(e); 298 String header = e.getErrorHeader(); 299 String body = e.getErrorBody(); 300 String msg; 301 if (header != null) { 302 if (body != null && !header.equals(body)) { 303 msg = header + " (" + body + ')'; 304 } else { 305 msg = header; 306 } 307 } else { 308 msg = body; 309 } 305 String msg = e.getDisplayMessage(); 310 306 311 307 if (msg != null && !msg.isEmpty()) { … … 726 722 } 727 723 724 /** 725 * Determines if the OSM API exception has been thrown because user has been blocked. 726 * @param e OSM API exception 727 * @return {@code true} if the OSM API exception has been thrown because user has been blocked 728 * @since 15084 729 */ 730 public static boolean isUserBlocked(OsmApiException e) { 731 return OSM_API_BLOCKED.equals(e.getErrorHeader()); 732 } 733 728 734 static String getUrlFromException(OsmApiException e) { 729 735 if (e.getAccessedUrl() != null) {
Note:
See TracChangeset
for help on using the changeset viewer.