[chromecast] Harmonize exception processing (#15225)

Rethrow a wrapped exception instead of only logging, like the other audio sinks.

Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
This commit is contained in:
Gwendal Roulleau 2023-07-12 10:54:42 +02:00 committed by GitHub
parent c6a22e04cb
commit 18ae834d68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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