-
Notifications
You must be signed in to change notification settings - Fork 1
/
ErrorMessageData.kt
46 lines (44 loc) · 1.57 KB
/
ErrorMessageData.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
package ch.srgssr.pillarbox.player.monitoring.models
import androidx.media3.common.Player
import ch.srgssr.pillarbox.player.extension.getPositionTimestamp
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents a [Player][androidx.media3.common.Player] error to send to a monitoring server.
*
* @property duration The duration of the media being player, in milliseconds.
* @property log The log associated with the error.
* @property message The error message.
* @property name The name of the error.
* @property position The position of the player when the error occurred, in milliseconds, or `null` if not available.
* @property positionTimestamp The current player timestamp, as retrieved from the playlist.
* @property url The last loaded url.
*/
@Serializable
data class ErrorMessageData(
val duration: Long?,
val log: String,
val message: String,
val name: String,
val position: Long?,
@SerialName("position_timestamp") val positionTimestamp: Long?,
val url: String,
) : MessageData {
constructor(
throwable: Throwable,
player: Player,
url: String,
) : this(
duration = player.duration,
log = throwable.stackTraceToString(),
message = throwable.message.orEmpty(),
name = throwable::class.simpleName.orEmpty(),
position = player.currentPosition,
positionTimestamp = player.getPositionTimestamp(),
url = url,
)
}