Changeset 9621 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-01-25T00:36:01+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r9616 r9621 98 98 Collection<PluginInformation> downloaded = task.getDownloadedPlugins(); 99 99 Collection<PluginInformation> failed = task.getFailedPlugins(); 100 Exception exception = task.getLastException(); 100 101 StringBuilder sb = new StringBuilder(); 101 102 if (!downloaded.isEmpty()) { … … 124 125 } 125 126 sb.append("</ul>"); 127 } 128 if (exception != null) { 129 // Same i18n string in ExceptionUtil.explainBadRequest() 130 sb.append(tr("<br>Error message(untranslated): {0}", exception.getMessage())); 126 131 } 127 132 return sb.toString(); -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadException.java
r3083 r9621 2 2 package org.openstreetmap.josm.plugins; 3 3 4 /** 5 * Exception thrown during plugin download. 6 * @since 2817 7 */ 4 8 public class PluginDownloadException extends Exception { 5 9 6 public PluginDownloadException() { 7 super(); 10 /** 11 * Constructs a new {@code PluginDownloadException} with the specified detail message and cause. 12 * @param message message the detail message (which is saved for later retrieval by the {@link #getMessage()} method). 13 * @param cause cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 14 */ 15 public PluginDownloadException(String message, Throwable cause) { 16 super(message, cause); 8 17 } 9 18 10 public PluginDownloadException(String arg0, Throwable arg1) { 11 super(arg0, arg1); 19 /** 20 * Constructs a new {@code PluginDownloadException} with the specified detail message. 21 * The cause is not initialized, and may subsequently be initialized by a call to {@link #initCause}. 22 * @param message message the detail message (which is saved for later retrieval by the {@link #getMessage()} method). 23 */ 24 public PluginDownloadException(String message) { 25 super(message); 12 26 } 13 27 14 public PluginDownloadException(String arg0) { 15 super(arg0); 16 } 17 18 public PluginDownloadException(Throwable arg0) { 19 super(arg0); 28 /** 29 * Constructs a new {@code PluginDownloadException} with the specified cause and a detail message of 30 * <tt>(cause==null ? null : cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>). 31 * @param cause cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 32 */ 33 public PluginDownloadException(Throwable cause) { 34 super(cause); 20 35 } 21 36 } -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r9309 r9621 30 30 * When the task is finished {@link #getDownloadedPlugins()} replies the list of downloaded plugins 31 31 * and {@link #getFailedPlugins()} replies the list of failed plugins. 32 * 32 * @since 2817 33 33 */ 34 34 public class PluginDownloadTask extends PleaseWaitRunnable { … … 43 43 private final Collection<PluginInformation> failed = new LinkedList<>(); 44 44 private final Collection<PluginInformation> downloaded = new LinkedList<>(); 45 private Exception lastException; 45 46 private boolean canceled; 46 47 private HttpClient downloadConnection; … … 97 98 98 99 @Override 99 protected void finish() {} 100 protected void finish() { 101 // Do nothing. Error/success feedback is managed in PluginPreference.notifyDownloadResults() 102 } 100 103 101 104 protected void download(PluginInformation pi, File file) throws PluginDownloadException { … … 150 153 File pluginDir = Main.pref.getPluginsDirectory(); 151 154 if (!pluginDir.exists() && !pluginDir.mkdirs()) { 152 /*lastException =*/ new PluginDownloadException(tr("Failed to create plugin directory ''{0}''", pluginDir.toString())); 155 String message = tr("Failed to create plugin directory ''{0}''", pluginDir.toString()); 156 lastException = new PluginDownloadException(message); 157 Main.error(message); 153 158 failed.addAll(toUpdate); 154 159 return; … … 156 161 getProgressMonitor().setTicksCount(toUpdate.size()); 157 162 for (PluginInformation d : toUpdate) { 158 if (canceled) return; 163 if (canceled) 164 return; 159 165 String message = tr("Downloading Plugin {0}...", d.name); 160 166 Main.info(message); … … 165 171 download(d, pluginFile); 166 172 } catch (PluginDownloadException e) { 173 lastException = e; 167 174 Main.error(e); 168 175 failed.add(d); … … 200 207 return downloaded; 201 208 } 209 210 /** 211 * Replies the last exception that occured during download, or {@code null}. 212 * @return the last exception that occured during download, or {@code null} 213 * @since 9621 214 */ 215 public Exception getLastException() { 216 return lastException; 217 } 202 218 }
Note:
See TracChangeset
for help on using the changeset viewer.