Commit 0df62a4f by aquilescanta Committed by bachinger

Add ERROR_CODE_FAILED_RUNTIME_CHECK for failed checks

PiperOrigin-RevId: 387143625
parent f9d94204
...@@ -937,7 +937,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { ...@@ -937,7 +937,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
throw new OpenException( throw new OpenException(
"HTTP request with non-empty body must set Content-Type", "HTTP request with non-empty body must set Content-Type",
dataSpec, dataSpec,
PlaybackException.ERROR_CODE_IO_BAD_HTTP_REQUEST, PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK,
Status.IDLE); Status.IDLE);
} }
......
...@@ -405,7 +405,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { ...@@ -405,7 +405,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
throw new HttpDataSourceException( throw new HttpDataSourceException(
"Malformed URL", "Malformed URL",
dataSpec, dataSpec,
PlaybackException.ERROR_CODE_IO_BAD_HTTP_REQUEST, PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK,
HttpDataSourceException.TYPE_OPEN); HttpDataSourceException.TYPE_OPEN);
} }
......
...@@ -46,6 +46,7 @@ public class PlaybackException extends Exception implements Bundleable { ...@@ -46,6 +46,7 @@ public class PlaybackException extends Exception implements Bundleable {
ERROR_CODE_REMOTE_ERROR, ERROR_CODE_REMOTE_ERROR,
ERROR_CODE_BEHIND_LIVE_WINDOW, ERROR_CODE_BEHIND_LIVE_WINDOW,
ERROR_CODE_TIMEOUT, ERROR_CODE_TIMEOUT,
ERROR_CODE_FAILED_RUNTIME_CHECK,
ERROR_CODE_IO_UNSPECIFIED, ERROR_CODE_IO_UNSPECIFIED,
ERROR_CODE_IO_NETWORK_UNAVAILABLE, ERROR_CODE_IO_NETWORK_UNAVAILABLE,
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED, ERROR_CODE_IO_NETWORK_CONNECTION_FAILED,
...@@ -94,6 +95,13 @@ public class PlaybackException extends Exception implements Bundleable { ...@@ -94,6 +95,13 @@ public class PlaybackException extends Exception implements Bundleable {
public static final int ERROR_CODE_BEHIND_LIVE_WINDOW = 1002; public static final int ERROR_CODE_BEHIND_LIVE_WINDOW = 1002;
/** Caused by a generic timeout. */ /** Caused by a generic timeout. */
public static final int ERROR_CODE_TIMEOUT = 1003; public static final int ERROR_CODE_TIMEOUT = 1003;
/**
* Caused by a failed runtime check.
*
* <p>This can happen when the application fails to comply with the player's API requirements (for
* example, by passing invalid arguments), or when the player reaches an invalid state.
*/
public static final int ERROR_CODE_FAILED_RUNTIME_CHECK = 1004;
// Input/Output errors (2xxx). // Input/Output errors (2xxx).
...@@ -217,6 +225,8 @@ public class PlaybackException extends Exception implements Bundleable { ...@@ -217,6 +225,8 @@ public class PlaybackException extends Exception implements Bundleable {
return "ERROR_CODE_BEHIND_LIVE_WINDOW"; return "ERROR_CODE_BEHIND_LIVE_WINDOW";
case ERROR_CODE_TIMEOUT: case ERROR_CODE_TIMEOUT:
return "ERROR_CODE_TIMEOUT"; return "ERROR_CODE_TIMEOUT";
case ERROR_CODE_FAILED_RUNTIME_CHECK:
return "ERROR_CODE_FAILED_RUNTIME_CHECK";
case ERROR_CODE_IO_UNSPECIFIED: case ERROR_CODE_IO_UNSPECIFIED:
return "ERROR_CODE_IO_UNSPECIFIED"; return "ERROR_CODE_IO_UNSPECIFIED";
case ERROR_CODE_IO_NETWORK_UNAVAILABLE: case ERROR_CODE_IO_NETWORK_UNAVAILABLE:
......
...@@ -599,7 +599,13 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -599,7 +599,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
} catch (IOException e) { } catch (IOException e) {
handleIoException(e, PlaybackException.ERROR_CODE_IO_UNSPECIFIED); handleIoException(e, PlaybackException.ERROR_CODE_IO_UNSPECIFIED);
} catch (RuntimeException e) { } catch (RuntimeException e) {
ExoPlaybackException error = ExoPlaybackException.createForUnexpected(e); @ErrorCode int errorCode;
if (e instanceof IllegalStateException || e instanceof IllegalArgumentException) {
errorCode = PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK;
} else {
errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED;
}
ExoPlaybackException error = ExoPlaybackException.createForUnexpected(e, errorCode);
Log.e(TAG, "Playback error", error); Log.e(TAG, "Playback error", error);
stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false); stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false);
playbackInfo = playbackInfo.copyWithPlaybackError(error); playbackInfo = playbackInfo.copyWithPlaybackError(error);
......
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