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
This commit is contained in:
ktrajkovski 2024-08-01 03:17:51 -07:00 committed by Copybara-Service
parent f3bf4ad5fe
commit 01593a9c1f

View File

@ -380,7 +380,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
// Expected if the app was built without the extension. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating VP9 extension", e); throw new IllegalStateException("Error instantiating VP9 extension", e);
} }
try { try {
@ -405,7 +405,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
// Expected if the app was built without the extension. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating AV1 extension", e); throw new IllegalStateException("Error instantiating AV1 extension", e);
} }
try { try {
@ -431,7 +431,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
// Expected if the app was built without the extension. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // 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. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating MIDI extension", e); throw new IllegalStateException("Error instantiating MIDI extension", e);
} }
try { try {
@ -507,7 +507,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
// Expected if the app was built without the extension. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating Opus extension", e); throw new IllegalStateException("Error instantiating Opus extension", e);
} }
try { try {
@ -526,7 +526,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
// Expected if the app was built without the extension. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating FLAC extension", e); throw new IllegalStateException("Error instantiating FLAC extension", e);
} }
try { try {
@ -545,7 +545,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
// Expected if the app was built without the extension. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating FFmpeg extension", e); throw new IllegalStateException("Error instantiating FFmpeg extension", e);
} }
try { try {
// Full class names used for constructor args so the LINT rule triggers if any of them move. // 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. // Expected if the app was built without the extension.
} catch (Exception e) { } catch (Exception e) {
// The extension is present, but instantiation failed. // The extension is present, but instantiation failed.
throw new RuntimeException("Error instantiating IAMF extension", e); throw new IllegalStateException("Error instantiating IAMF extension", e);
} }
} }