Include source/sink details in exceptions.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 25 May 2013 09:24:01 +0000 (11:24 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 27 May 2013 20:54:37 +0000 (22:54 +0200)
src/main/java/net/pterodactylus/sonitus/data/Pipeline.java

index 93648bc..b45d346 100644 (file)
@@ -261,7 +261,12 @@ public class Pipeline {
                                try {
                                        final Metadata lastMetadata = firstMetadata;
                                        final Metadata metadata = firstMetadata = source.metadata();
-                                       final byte[] buffer = source.get(4096);
+                                       final byte[] buffer;
+                                       try {
+                                               buffer = source.get(4096);
+                                       } catch (IOException ioe1) {
+                                               throw new IOException(String.format("I/O error while reading from %s.", source), ioe1);
+                                       }
                                        List<Future<Void>> futures = executorService.invokeAll(FluentIterable.from(sinks).transform(new Function<Sink, Callable<Void>>() {
 
                                                @Override
@@ -273,7 +278,11 @@ public class Pipeline {
                                                                        if (!metadata.equals(lastMetadata)) {
                                                                                sink.metadataUpdated(metadata);
                                                                        }
-                                                                       sink.process(buffer);
+                                                                       try {
+                                                                               sink.process(buffer);
+                                                                       } catch (IOException ioe1) {
+                                                                               throw new IOException(String.format("I/O error while writing to %s", sink), ioe1);
+                                                                       }
                                                                        return null;
                                                                }
                                                        };