Skip to content

Commit ece95f7

Browse files
committed
Added more error info for non-production
Signed-off-by: Arnau Mora Gras <[email protected]>
1 parent d259310 commit ece95f7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/main/kotlin/server/endpoints/files/DownloadFileEndpoint.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import server.error.Errors
1515
import server.response.respondFailure
1616
import storage.Storage
1717
import utils.ImageUtils
18+
import utils.jsonOf
1819

1920
object DownloadFileEndpoint : EndpointBase("/download/{uuid}") {
2021
override suspend fun PipelineContext<Unit, ApplicationCall>.endpoint() {
@@ -23,7 +24,15 @@ object DownloadFileEndpoint : EndpointBase("/download/{uuid}") {
2324
val width = call.parameters["width"]?.toIntOrNull()
2425
val height = call.parameters["height"]?.toIntOrNull()
2526

26-
val file = Storage.find(uuid) ?: return respondFailure(Errors.FileNotFound)
27+
val file = Storage.find(uuid) ?: return respondFailure(
28+
Errors.FileNotFound.withExtra(
29+
jsonOf(
30+
"ImagesDir" to Storage.ImagesDir.absolutePath,
31+
"TracksDir" to Storage.TracksDir.absolutePath,
32+
"uuid" to uuid
33+
)
34+
)
35+
)
2736

2837
// Add the file's MIME type to the response
2938
withContext(Dispatchers.IO) {

src/main/kotlin/server/endpoints/files/RequestFileEndpoint.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ object RequestFileEndpoint : EndpointBase("/file/{uuids}") {
5858
}
5959
)
6060
} catch (_: FileNotFoundException) {
61-
respondFailure(Errors.FileNotFound)
61+
respondFailure(
62+
Errors.FileNotFound.withExtra(
63+
jsonOf(
64+
"ImagesDir" to Storage.ImagesDir.absolutePath,
65+
"TracksDir" to Storage.TracksDir.absolutePath,
66+
"list" to list
67+
)
68+
)
69+
)
6270
}
6371
}
6472
}

0 commit comments

Comments
 (0)