Commit 6d04b998 by claincly Committed by Oliver Woodman

Use more factory method to create ParserException.

ParserException's constructor methods are deprecated.

#minor-release

PiperOrigin-RevId: 376150191
parent 41ce635a
...@@ -51,6 +51,20 @@ public class ParserException extends IOException { ...@@ -51,6 +51,20 @@ public class ParserException extends IOException {
/** /**
* Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is * Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is
* {@link C#DATA_TYPE_MANIFEST}.
*
* @param message See {@link #getMessage()}.
* @param cause See {@link #getCause()}.
* @return The created instance.
*/
public static ParserException createForManifestWithUnsupportedFeature(
@Nullable String message, @Nullable Throwable cause) {
return new ParserException(
message, cause, /* contentIsMalformed= */ false, C.DATA_TYPE_MANIFEST);
}
/**
* Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is
* {@link C#DATA_TYPE_MEDIA}. * {@link C#DATA_TYPE_MEDIA}.
* *
* @param message See {@link #getMessage()}. * @param message See {@link #getMessage()}.
......
...@@ -95,7 +95,8 @@ import java.security.NoSuchAlgorithmException; ...@@ -95,7 +95,8 @@ import java.security.NoSuchAlgorithmException;
case DIGEST: case DIGEST:
return getDigestAuthorizationHeaderValue(authUserInfo, uri, requestMethod); return getDigestAuthorizationHeaderValue(authUserInfo, uri, requestMethod);
default: default:
throw new ParserException(new UnsupportedOperationException()); throw ParserException.createForManifestWithUnsupportedFeature(
/* message= */ null, new UnsupportedOperationException());
} }
} }
...@@ -136,7 +137,7 @@ import java.security.NoSuchAlgorithmException; ...@@ -136,7 +137,7 @@ import java.security.NoSuchAlgorithmException;
DIGEST_FORMAT_WITH_OPAQUE, authUserInfo.username, realm, nonce, uri, response, opaque); DIGEST_FORMAT_WITH_OPAQUE, authUserInfo.username, realm, nonce, uri, response, opaque);
} }
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new ParserException(e); throw ParserException.createForManifestWithUnsupportedFeature(/* message= */ null, e);
} }
} }
} }
...@@ -421,7 +421,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -421,7 +421,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable @Nullable
String wwwAuthenticateHeader = response.headers.get(RtspHeaders.WWW_AUTHENTICATE); String wwwAuthenticateHeader = response.headers.get(RtspHeaders.WWW_AUTHENTICATE);
if (wwwAuthenticateHeader == null) { if (wwwAuthenticateHeader == null) {
throw new ParserException("Missing WWW-Authenticate header in a 401 response."); throw ParserException.createForMalformedManifest(
"Missing WWW-Authenticate header in a 401 response.", /* cause= */ null);
} }
rtspAuthenticationInfo = rtspAuthenticationInfo =
RtspMessageUtil.parseWwwAuthenticateHeader(wwwAuthenticateHeader); RtspMessageUtil.parseWwwAuthenticateHeader(wwwAuthenticateHeader);
......
...@@ -426,7 +426,8 @@ import java.util.regex.Pattern; ...@@ -426,7 +426,8 @@ import java.util.regex.Pattern;
/* nonce= */ "", /* nonce= */ "",
/* opaque= */ ""); /* opaque= */ "");
} }
throw new ParserException("Invalid WWW-Authenticate header " + headerValue); throw ParserException.createForMalformedManifest(
"Invalid WWW-Authenticate header " + headerValue, /* cause= */ null);
} }
private static String getRtspStatusReasonPhrase(int statusCode) { private static String getRtspStatusReasonPhrase(int statusCode) {
......
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