]> git.basschouten.com Git - openhab-addons.git/commitdiff
[chromecast] Harmonize exception processing (#15225)
authorGwendal Roulleau <dalgwen@users.noreply.github.com>
Wed, 12 Jul 2023 08:54:42 +0000 (10:54 +0200)
committerGitHub <noreply@github.com>
Wed, 12 Jul 2023 08:54:42 +0000 (10:54 +0200)
Rethrow a wrapped exception instead of only logging, like the other audio sinks.

Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
bundles/org.openhab.binding.chromecast/src/main/java/org/openhab/binding/chromecast/internal/ChromecastAudioSink.java

index 538015f26aca0c9ff26c5c3b30dd50ee728f55c6..80a6ab3c3a6fc7bd1cd120c6294b2a6cd2244fc7 100644 (file)
@@ -27,6 +27,7 @@ import org.openhab.core.audio.AudioStream;
 import org.openhab.core.audio.StreamServed;
 import org.openhab.core.audio.URLAudioStream;
 import org.openhab.core.audio.UnsupportedAudioFormatException;
+import org.openhab.core.audio.UnsupportedAudioStreamException;
 import org.openhab.core.library.types.PercentType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,7 +69,8 @@ public class ChromecastAudioSink extends AudioSinkAsync {
     }
 
     @Override
-    public void processAsynchronously(@Nullable AudioStream audioStream) throws UnsupportedAudioFormatException {
+    public void processAsynchronously(@Nullable AudioStream audioStream)
+            throws UnsupportedAudioFormatException, UnsupportedAudioStreamException {
         if (audioStream == null) {
             // in case the audioStream is null, this should be interpreted as a request to end any currently playing
             // stream.
@@ -91,10 +93,10 @@ public class ChromecastAudioSink extends AudioSinkAsync {
                         // we have to run the delayed task when the server has completely played the stream
                         streamServed.playEnd().thenRun(() -> this.playbackFinished(audioStream));
                     } catch (IOException e) {
-                        logger.warn("Chromecast binding was not able to handle the audio stream (cache on disk failed)",
-                                e);
                         tryClose(audioStream);
-                        return;
+                        throw new UnsupportedAudioStreamException(
+                                "Chromecast binding was not able to handle the audio stream (cache on disk failed)",
+                                audioStream.getClass(), e);
                     }
                     url = callbackUrl + relativeUrl;
                 } else {