From 01593a9c1fe55f0148f64865d3da48ddc184f6b6 Mon Sep 17 00:00:00 2001 From: ktrajkovski Date: Thu, 1 Aug 2024 03:17:51 -0700 Subject: [PATCH] Replace `RuntimeException` with `IllegalStateException`. Refactor to replace instances of `RuntimeException` with `IllegalStateException`. This change ensures exceptions can be handled more specifically without unintended catches of unrelated exceptions. PiperOrigin-RevId: 658337459 --- .../exoplayer/DefaultRenderersFactory.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java index 1b50d7b974..266ed047d8 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java @@ -380,7 +380,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating VP9 extension", e); + throw new IllegalStateException("Error instantiating VP9 extension", e); } try { @@ -405,7 +405,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating AV1 extension", e); + throw new IllegalStateException("Error instantiating AV1 extension", e); } try { @@ -431,7 +431,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating FFmpeg extension", e); + throw new IllegalStateException("Error instantiating FFmpeg extension", e); } } @@ -488,7 +488,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating MIDI extension", e); + throw new IllegalStateException("Error instantiating MIDI extension", e); } try { @@ -507,7 +507,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating Opus extension", e); + throw new IllegalStateException("Error instantiating Opus extension", e); } try { @@ -526,7 +526,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating FLAC extension", e); + throw new IllegalStateException("Error instantiating FLAC extension", e); } try { @@ -545,7 +545,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating FFmpeg extension", e); + throw new IllegalStateException("Error instantiating FFmpeg extension", e); } try { // Full class names used for constructor args so the LINT rule triggers if any of them move. @@ -562,7 +562,7 @@ public class DefaultRenderersFactory implements RenderersFactory { // Expected if the app was built without the extension. } catch (Exception e) { // The extension is present, but instantiation failed. - throw new RuntimeException("Error instantiating IAMF extension", e); + throw new IllegalStateException("Error instantiating IAMF extension", e); } }