Add errorCode to the EventLogger

PiperOrigin-RevId: 376126959
This commit is contained in:
aquilescanta 2021-05-27 10:37:11 +01:00 committed by Oliver Woodman
parent 0fb5fa75cf
commit c353151288
2 changed files with 12 additions and 0 deletions

View file

@ -243,6 +243,14 @@ public class PlaybackException extends Exception implements Bundleable {
}
}
/**
* Equivalent to {@link PlaybackException#getErrorCodeName(int)
* PlaybackException.getErrorCodeName(this.errorCode)}.
*/
public final String getErrorCodeName() {
return getErrorCodeName(errorCode);
}
/** An error code which identifies the cause of the playback failure. */
@ErrorCode public final int errorCode;

View file

@ -24,6 +24,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
@ -598,6 +599,9 @@ public class EventLogger implements AnalyticsListener {
@Nullable String eventDescription,
@Nullable Throwable throwable) {
String eventString = eventName + " [" + getEventTimeString(eventTime);
if (throwable instanceof PlaybackException) {
eventString += ", errorCode=" + ((PlaybackException) throwable).getErrorCodeName();
}
if (eventDescription != null) {
eventString += ", " + eventDescription;
}