Commit 1c429417 by aquilescanta Committed by Oliver Woodman

Add contentIsMalformed and dataType to ParserException

PiperOrigin-RevId: 374874272
parent 08259f89
...@@ -15,30 +15,101 @@ ...@@ -15,30 +15,101 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C.DataType;
import java.io.IOException; import java.io.IOException;
/** Thrown when an error occurs parsing media data and metadata. */ /** Thrown when an error occurs parsing media data and metadata. */
public class ParserException extends IOException { public class ParserException extends IOException {
/**
* Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
* {@link C#DATA_TYPE_MEDIA}.
*
* @param message See {@link #getMessage()}.
* @param cause See {@link #getCause()}.
* @return The created instance.
*/
public static ParserException createForMalformedContainer(
@Nullable String message, @Nullable Throwable cause) {
return new ParserException(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_MEDIA);
}
/**
* Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is
* {@link C#DATA_TYPE_MEDIA}.
*
* @param message See {@link #getMessage()}.
* @return The created instance.
*/
public static ParserException createForUnsupportedContainerFeature(@Nullable String message) {
return new ParserException(
message, /* cause= */ null, /* contentIsMalformed= */ false, C.DATA_TYPE_MEDIA);
}
/**
* Whether the parsing error was caused by a bitstream not following the expected format. May be
* false when a parser encounters a legal condition which it does not support.
*/
public final boolean contentIsMalformed;
/** The {@link DataType data type} of the parsed bitstream. */
public final int dataType;
/**
* Creates a new instance.
*
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
* #dataType} instead.
*/
@Deprecated
public ParserException() { public ParserException() {
super(); this(/* message= */ null, /* cause= */ null);
} }
/** @param message The detail message for the exception. */ /**
* Creates a new instance.
*
* @param message The detail message for the exception.
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
* #dataType} instead.
*/
@Deprecated
public ParserException(String message) { public ParserException(String message) {
super(message); this(message, /* cause= */ null);
} }
/** @param cause The cause for the exception. */ /**
* Creates a new instance.
*
* @param cause The cause for the exception.
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
* #dataType} instead.
*/
@Deprecated
public ParserException(Throwable cause) { public ParserException(Throwable cause) {
super(cause); this(/* message= */ null, cause);
} }
/** /**
* Creates a new instance.
*
* @param message The detail message for the exception. * @param message The detail message for the exception.
* @param cause The cause for the exception. * @param cause The cause for the exception.
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
* #dataType} instead.
*/ */
public ParserException(String message, Throwable cause) { @Deprecated
public ParserException(@Nullable String message, @Nullable Throwable cause) {
this(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
}
private ParserException(
@Nullable String message,
@Nullable Throwable cause,
boolean contentIsMalformed,
@DataType int dataType) {
super(message, cause); super(message, cause);
this.contentIsMalformed = contentIsMalformed;
this.dataType = dataType;
} }
} }
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