1
1
package org .optimizationBenchmarking .documentation .examples ;
2
2
3
3
import java .io .BufferedReader ;
4
+ import java .io .IOException ;
4
5
import java .io .InputStream ;
5
6
import java .io .InputStreamReader ;
6
7
import java .net .URI ;
@@ -62,7 +63,7 @@ static final URI _resolveExampleURI(final URI baseUri, final String id) {
62
63
63
64
/** {@inheritDoc} */
64
65
@ Override
65
- public final Path call () throws Exception {
66
+ public final Path call () throws IOException {
66
67
final URI exampleUri ;
67
68
final Path destDirectory ;
68
69
final Logger logger ;
@@ -168,16 +169,16 @@ public final Path call() throws Exception {
168
169
* @param found
169
170
* did we already create something?
170
171
* @return {@code true} if a file was unpacked, {@code false} otherwise
171
- * @throws Exception
172
+ * @throws IOException
172
173
* if something goes wrong
173
174
*/
174
175
private final boolean __process (final String line , final URI baseUri ,
175
- final Path destFolder , final boolean found ) throws Exception {
176
+ final Path destFolder , final boolean found ) throws IOException {
176
177
final Logger logger ;
177
178
final URL url ;
178
179
final Path destPath ;
179
180
final boolean zip ;
180
- String path ;
181
+ String path , message ;
181
182
int index ;
182
183
char ch ;
183
184
@@ -188,9 +189,10 @@ private final boolean __process(final String line, final URI baseUri,
188
189
189
190
logger = this .getLogger ();
190
191
url = baseUri .resolve (path ).toURL ();
192
+ message = null ;
191
193
if ((logger != null ) && (logger .isLoggable (Level .FINE ))) {
192
- logger . fine ((( "Now downloading resource '" + url ) //$NON-NLS-1$
193
- + '\'' ) + '.' );
194
+ message = (( " resource '" + url ) + '\'' ); //$NON-NLS-1$
195
+ logger . fine (( "Now downloading " + message ) + '.' );//$NON-NLS-1$
194
196
}
195
197
196
198
if (!(found )) {
@@ -215,10 +217,14 @@ private final boolean __process(final String line, final URI baseUri,
215
217
}
216
218
217
219
if ((logger != null ) && (logger .isLoggable (Level .FINE ))) {
218
- logger .fine ((("Beginning to download resource '" + url + //$NON-NLS-1$
219
- (zip ? "' as zip archive into folder '" //$NON-NLS-1$
220
- : "' as file into file '" )//$NON-NLS-1$
221
- + destPath ) + '\'' ) + '.' );
220
+ if (message == null ) {
221
+ message = (("resource '" + url ) + '\'' );//$NON-NLS-1$
222
+ }
223
+ message = (((message + (zip //
224
+ ? " as zip archive into folder '" //$NON-NLS-1$
225
+ : " as file into file '" ))//$NON-NLS-1$
226
+ + destPath ) + '\'' );
227
+ logger .fine ("Beginning to download " + message + '.' );//$NON-NLS-1$
222
228
}
223
229
224
230
try (final InputStream input = url .openStream ()) {
@@ -227,11 +233,25 @@ private final boolean __process(final String line, final URI baseUri,
227
233
} else {
228
234
Files .copy (input , destPath );
229
235
}
236
+ } catch (final Throwable error ) {
237
+ if (message == null ) {
238
+ message = (((("resource '" + url ) //$NON-NLS-1$
239
+ + (zip ? "' as zip archive into folder '" //$NON-NLS-1$
240
+ : "' as file into file '" ))//$NON-NLS-1$
241
+ + destPath ) + '\'' );
242
+ }
243
+ throw new IOException ((("Error while downloading " //$NON-NLS-1$
244
+ + message ) + '.' ), error );
230
245
}
231
246
232
247
if ((logger != null ) && (logger .isLoggable (Level .FINE ))) {
233
- logger .fine ((("Finished downloading resource '" + url ) //$NON-NLS-1$
234
- + '\'' ) + '.' );
248
+ if (message == null ) {
249
+ message = (((("resource '" + url ) //$NON-NLS-1$
250
+ + (zip ? "' as zip archive into folder '" //$NON-NLS-1$
251
+ : "' as file into file '" ))//$NON-NLS-1$
252
+ + destPath ) + '\'' );
253
+ }
254
+ logger .fine (("Finished downloading " + message ) + '.' );//$NON-NLS-1$
235
255
}
236
256
237
257
return true ;
0 commit comments