Skip to content

Commit a5e8694

Browse files
committed
Add debug logging if the product ID could not be resolved to a download URL
1 parent a7c8202 commit a5e8694

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/main/kotlin/net/kautler/github/action/setup_wsl/Distribution.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package net.kautler.github.action.setup_wsl
1919
import SemVer
2020
import actions.core.debug
2121
import actions.core.info
22+
import actions.core.isDebug
2223
import actions.exec.exec
2324
import actions.http.client.HttpClient
2425
import js.core.jso
@@ -67,6 +68,35 @@ sealed class Distribution(
6768
).await()
6869

6970
if (response.message.statusCode != 200) {
71+
if (isDebug()) {
72+
val echoResponse = HttpClient().post(
73+
requestUrl = "https://echo.free.beeceptor.com/api/GetFiles",
74+
data = "type=ProductId&url=$productId",
75+
additionalHeaders = recordOf(
76+
"Content-Type" to "application/x-www-form-urlencoded"
77+
)
78+
).await()
79+
if (echoResponse.message.statusCode == 200) {
80+
debug("Request:\n${echoResponse.readBody().await()}")
81+
} else {
82+
debug("Could not get echo response (statusCode: ${echoResponse.message.statusCode} / statusMessage: ${echoResponse.message.statusMessage})")
83+
}
84+
85+
val responseMessage = JSON.stringify(
86+
recordOf(
87+
"httpVersion" to response.message.httpVersion,
88+
"headers" to response.message.headers,
89+
"trailers" to response.message.trailers,
90+
"method" to (response.message.method ?: "<unknown>"),
91+
"url" to (response.message.url ?: "<unknown>"),
92+
"statusCode" to (response.message.statusCode ?: "<unknown>"),
93+
"statusMessage" to (response.message.statusMessage ?: "<unknown>"),
94+
"body" to response.readBody().await()
95+
),
96+
space = 2
97+
)
98+
debug("Response:\n$responseMessage")
99+
}
70100
error("Could not determine download URL (statusCode: ${response.message.statusCode} / statusMessage: ${response.message.statusMessage})")
71101
}
72102

0 commit comments

Comments
 (0)