Commit 61c92007 by aquilescanta Committed by Oliver Woodman

Bubble up the errorCode argument in preparation for new factory methods

Notes:
- The only functional change is that createForRemote now assings ERROR_CODE_REMOTE_ERROR.
- createForSource still uses ERROR_CODE_UNSPECIFIED, even though it expects an
  IOException. The reason for not using ERROR_CODE_IO_UNSPECIFIED is that the reason for
  the error might not be IO. For example, malformed media, or BehindLiveWindowException,
  which have non-IO error codes. So using UNSPECIFIED saves a later change in category.
PiperOrigin-RevId: 374390407
parent 378b3f6e
...@@ -114,7 +114,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -114,7 +114,7 @@ public final class ExoPlaybackException extends PlaybackException {
* @return The created instance. * @return The created instance.
*/ */
public static ExoPlaybackException createForSource(IOException cause) { public static ExoPlaybackException createForSource(IOException cause) {
return new ExoPlaybackException(TYPE_SOURCE, cause); return new ExoPlaybackException(TYPE_SOURCE, cause, ERROR_CODE_UNSPECIFIED);
} }
/** /**
...@@ -128,6 +128,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -128,6 +128,7 @@ public final class ExoPlaybackException extends PlaybackException {
TYPE_RENDERER, TYPE_RENDERER,
cause, cause,
/* customMessage= */ null, /* customMessage= */ null,
ERROR_CODE_UNSPECIFIED,
/* rendererName */ null, /* rendererName */ null,
/* rendererIndex= */ C.INDEX_UNSET, /* rendererIndex= */ C.INDEX_UNSET,
/* rendererFormat= */ null, /* rendererFormat= */ null,
...@@ -184,6 +185,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -184,6 +185,7 @@ public final class ExoPlaybackException extends PlaybackException {
TYPE_RENDERER, TYPE_RENDERER,
cause, cause,
/* customMessage= */ null, /* customMessage= */ null,
ERROR_CODE_UNSPECIFIED,
rendererName, rendererName,
rendererIndex, rendererIndex,
rendererFormat, rendererFormat,
...@@ -198,7 +200,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -198,7 +200,7 @@ public final class ExoPlaybackException extends PlaybackException {
* @return The created instance. * @return The created instance.
*/ */
public static ExoPlaybackException createForUnexpected(RuntimeException cause) { public static ExoPlaybackException createForUnexpected(RuntimeException cause) {
return new ExoPlaybackException(TYPE_UNEXPECTED, cause); return new ExoPlaybackException(TYPE_UNEXPECTED, cause, ERROR_CODE_UNSPECIFIED);
} }
/** /**
...@@ -208,14 +210,11 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -208,14 +210,11 @@ public final class ExoPlaybackException extends PlaybackException {
* @return The created instance. * @return The created instance.
*/ */
public static ExoPlaybackException createForRemote(String message) { public static ExoPlaybackException createForRemote(String message) {
return new ExoPlaybackException(TYPE_REMOTE, message); return new ExoPlaybackException(
} TYPE_REMOTE,
/* cause= */ null,
private ExoPlaybackException(@Type int type, Throwable cause) { /* customMessage= */ message,
this( ERROR_CODE_REMOTE_ERROR,
type,
cause,
/* customMessage= */ null,
/* rendererName= */ null, /* rendererName= */ null,
/* rendererIndex= */ C.INDEX_UNSET, /* rendererIndex= */ C.INDEX_UNSET,
/* rendererFormat= */ null, /* rendererFormat= */ null,
...@@ -223,11 +222,12 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -223,11 +222,12 @@ public final class ExoPlaybackException extends PlaybackException {
/* isRecoverable= */ false); /* isRecoverable= */ false);
} }
private ExoPlaybackException(@Type int type, String message) { private ExoPlaybackException(@Type int type, Throwable cause, @ErrorCode int errorCode) {
this( this(
type, type,
/* cause= */ null, cause,
/* customMessage= */ message, /* customMessage= */ null,
errorCode,
/* rendererName= */ null, /* rendererName= */ null,
/* rendererIndex= */ C.INDEX_UNSET, /* rendererIndex= */ C.INDEX_UNSET,
/* rendererFormat= */ null, /* rendererFormat= */ null,
...@@ -239,6 +239,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -239,6 +239,7 @@ public final class ExoPlaybackException extends PlaybackException {
@Type int type, @Type int type,
@Nullable Throwable cause, @Nullable Throwable cause,
@Nullable String customMessage, @Nullable String customMessage,
@ErrorCode int errorCode,
@Nullable String rendererName, @Nullable String rendererName,
int rendererIndex, int rendererIndex,
@Nullable Format rendererFormat, @Nullable Format rendererFormat,
...@@ -253,6 +254,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -253,6 +254,7 @@ public final class ExoPlaybackException extends PlaybackException {
rendererFormat, rendererFormat,
rendererFormatSupport), rendererFormatSupport),
cause, cause,
errorCode,
type, type,
rendererName, rendererName,
rendererIndex, rendererIndex,
...@@ -280,6 +282,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -280,6 +282,7 @@ public final class ExoPlaybackException extends PlaybackException {
private ExoPlaybackException( private ExoPlaybackException(
String message, String message,
@Nullable Throwable cause, @Nullable Throwable cause,
@ErrorCode int errorCode,
@Type int type, @Type int type,
@Nullable String rendererName, @Nullable String rendererName,
int rendererIndex, int rendererIndex,
...@@ -288,7 +291,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -288,7 +291,7 @@ public final class ExoPlaybackException extends PlaybackException {
@Nullable MediaPeriodId mediaPeriodId, @Nullable MediaPeriodId mediaPeriodId,
long timestampMs, long timestampMs,
boolean isRecoverable) { boolean isRecoverable) {
super(message, cause, ERROR_CODE_UNSPECIFIED, timestampMs); super(message, cause, errorCode, timestampMs);
Assertions.checkArgument(!isRecoverable || type == TYPE_RENDERER); Assertions.checkArgument(!isRecoverable || type == TYPE_RENDERER);
Assertions.checkArgument(cause != null || type == TYPE_REMOTE); Assertions.checkArgument(cause != null || type == TYPE_REMOTE);
this.type = type; this.type = type;
...@@ -341,6 +344,7 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -341,6 +344,7 @@ public final class ExoPlaybackException extends PlaybackException {
return new ExoPlaybackException( return new ExoPlaybackException(
Util.castNonNull(getMessage()), Util.castNonNull(getMessage()),
getCause(), getCause(),
errorCode,
type, type,
rendererName, rendererName,
rendererIndex, rendererIndex,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment