Skip to content

Commit c371e9f

Browse files
committed
add new causeStackTrace field in exception
1 parent eaac192 commit c371e9f

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

LavalinkServer/src/main/java/lavalink/server/player/EventEmitter.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ class EventEmitter(
7676

7777
// These exceptions are already logged by Lavaplayer
7878
override fun onTrackException(player: AudioPlayer, track: AudioTrack, exception: FriendlyException) {
79+
val rootCause = getRootCause(exception)
80+
7981
this.player.socketContext.sendMessage(
8082
Message.Serializer,
8183
Message.EmittedEvent.TrackExceptionEvent(
8284
this.player.guildId.toString(),
8385
track.toTrack(audioPlayerManager, pluginInfoModifiers),
84-
Exception(exception.message, exception.severity.toLavalink(), getRootCause(exception).toString())
86+
Exception(exception.message, exception.severity.toLavalink(), rootCause.toString(), rootCause.stackTraceToString())
8587
)
8688
)
8789
}

LavalinkServer/src/main/java/lavalink/server/util/util.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ fun FriendlyException.Severity.toLavalink() = when (this) {
154154
fun Exception.Companion.fromFriendlyException(e: FriendlyException) = Exception(
155155
e.message,
156156
Exception.Severity.fromFriendlyException(e.severity),
157+
e.toString(),
157158
e.stackTraceToString()
158159
)
159160

docs/api/rest.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ When Lavalink encounters an error, it will respond with a JSON object containing
4646

4747
</details>
4848

49-
5049
## Track API
5150

52-
### Common Types ### {: #track-api-types }
51+
### Common Types ### {: #track-api-types }
5352

5453
#### Track
5554

@@ -89,16 +88,14 @@ When Lavalink encounters an error, it will respond with a JSON object containing
8988

9089
This endpoint is used to resolve audio tracks for use with the [Update Player](#update-player) endpoint.
9190

92-
9391
!!! tip
94-
92+
9593
Lavalink supports searching via YouTube, YouTube Music, and Soundcloud. To search, you must prefix your identifier with `ytsearch:`, `ytmsearch:` or `scsearch:` respectively.
9694

9795
When a search prefix is used, the returned `loadType` will be `search`. Note that disabling the respective source managers renders these search prefixes useless.
9896

9997
Plugins may also implement prefixes to allow for more search engines to be utilised.
10098

101-
10299
```
103100
GET /v4/loadtracks?identifier=dQw4w9WgXcQ
104101
```
@@ -203,7 +200,7 @@ Empty object.
203200
```yaml
204201
{
205202
"loadType": "empty",
206-
"data": {}
203+
"data": { }
207204
}
208205
```
209206

@@ -219,10 +216,11 @@ Empty object.
219216
```yaml
220217
{
221218
"loadType": "error",
222-
"data": {
219+
"data": {
223220
"message": "Something went wrong",
224221
"severity": "fault",
225-
"cause": "..."
222+
"cause": "...",
223+
"causeStackTrace": "...",
226224
}
227225
}
228226
```
@@ -330,7 +328,7 @@ Array of [Track](#track) objects
330328

331329
## Player API
332330

333-
### Common Types ### {: #player-api-types }
331+
### Common Types ### {: #player-api-types }
334332

335333
#### Player
336334

@@ -356,7 +354,6 @@ Array of [Track](#track) objects
356354
`sessionId` is provided by the Voice State Update event sent by Discord, whereas the `endpoint` and `token` are provided
357355
with the Voice Server Update. Please refer to https://discord.com/developers/docs/topics/gateway-events#voice
358356

359-
360357
#### Filters
361358

362359
Filters are used in above requests and look like this
@@ -731,7 +728,7 @@ When `identifier` is used, Lavalink will try to resolve the identifier as a sing
731728
{
732729
"track": {
733730
"encoded": "...",
734-
"identifier": "...",
731+
"identifier": "...",
735732
"userData": { ... }
736733
},
737734
"endTime": 0,
@@ -781,7 +778,7 @@ Response:
781778
"time": 1500467109,
782779
"position": 60000,
783780
"connected": true,
784-
"ping": 50
781+
"ping": 50
785782
},
786783
"voice": {
787784
"token": "...",
@@ -1018,7 +1015,6 @@ Response:
10181015

10191016
Additionally, there are a few REST endpoints for the ip rotation extension.
10201017

1021-
10221018
### Common Types ### {: #route-planner-api-types }
10231019

10241020
#### Route Planner Types

docs/api/websocket.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ Dispatched when a track throws an exception.
331331

332332
##### Exception Object
333333

334-
| Field | Type | Description |
335-
|----------|-----------------------|-------------------------------|
336-
| message | ?string | The message of the exception |
337-
| severity | [Severity](#severity) | The severity of the exception |
338-
| cause | string | The cause of the exception |
334+
| Field | Type | Description |
335+
|-----------------|-----------------------|-----------------------------------|
336+
| message | ?string | The message of the exception |
337+
| severity | [Severity](#severity) | The severity of the exception |
338+
| cause | string | The cause of the exception |
339+
| causeStackTrace | string | The full stack trace of the cause |
339340

340341
##### Severity
341342

@@ -373,7 +374,8 @@ Dispatched when a track throws an exception.
373374
"exception": {
374375
"message": "...",
375376
"severity": "common",
376-
"cause": "..."
377+
"cause": "...",
378+
"causeStackTrace": "..."
377379
}
378380
}
379381
```

protocol/src/commonMain/kotlin/dev/arbjerg/lavalink/protocol/v4/loadResult.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ data class Playlist(
151151
data class Exception(
152152
val message: String?,
153153
val severity: Severity,
154-
val cause: String
154+
val cause: String,
155+
val causeStackTrace: String
155156
) : LoadResult.Data {
156157

157158
/**

protocol/src/commonTest/kotlin/LoadResultSerializerTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class LoadResultSerializerTest {
7070
"data": {
7171
"message": "The uploader has not made this video available in your country.",
7272
"severity": "common",
73-
"cause": "com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video is not available in your country."
73+
"cause": "com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video is not available in your country.",
74+
"causeStackTrace": "com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video is not available in your country.\n\nblabla"
7475
}
7576
}
7677
""".trimIndent()
@@ -83,6 +84,7 @@ class LoadResultSerializerTest {
8384
message shouldBe "The uploader has not made this video available in your country."
8485
severity shouldBe Exception.Severity.COMMON
8586
cause shouldBe "com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video is not available in your country."
87+
causeStackTrace shouldBe "com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video is not available in your country.\n\nblabla"
8688
}
8789
}
8890
}

0 commit comments

Comments
 (0)