Return an optional instead of throwing an exception.
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / io / IdentifyingInputStream.java
index 537c9a4..7cc69b0 100644 (file)
@@ -83,11 +83,9 @@ public class IdentifyingInputStream extends FilterInputStream {
                RememberingInputStream rememberingInputStream = new RememberingInputStream(inputStream);
 
                /* try Ogg Vorbis first. */
-               try {
-                       Format format = OggVorbisIdentifier.identify(rememberingInputStream);
-                       return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), format));
-               } catch (IdentifierException ie1) {
-                       rememberingInputStream = new RememberingInputStream(rememberingInputStream.remembered());
+               Optional<Format> format = OggVorbisIdentifier.identify(rememberingInputStream);
+               if (format.isPresent()) {
+                       return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), format.get()));
                }
 
                return Optional.absent();