Skip to content

Commit

Permalink
Add debug logging if the product ID could not be resolved to a downlo…
Browse files Browse the repository at this point in the history
…ad URL
  • Loading branch information
Vampire committed May 26, 2024
1 parent a7c8202 commit a5e8694
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package net.kautler.github.action.setup_wsl
import SemVer
import actions.core.debug
import actions.core.info
import actions.core.isDebug
import actions.exec.exec
import actions.http.client.HttpClient
import js.core.jso
Expand Down Expand Up @@ -67,6 +68,35 @@ sealed class Distribution(
).await()

if (response.message.statusCode != 200) {
if (isDebug()) {
val echoResponse = HttpClient().post(
requestUrl = "https://echo.free.beeceptor.com/api/GetFiles",
data = "type=ProductId&url=$productId",
additionalHeaders = recordOf(
"Content-Type" to "application/x-www-form-urlencoded"
)
).await()
if (echoResponse.message.statusCode == 200) {
debug("Request:\n${echoResponse.readBody().await()}")
} else {
debug("Could not get echo response (statusCode: ${echoResponse.message.statusCode} / statusMessage: ${echoResponse.message.statusMessage})")
}

val responseMessage = JSON.stringify(
recordOf(
"httpVersion" to response.message.httpVersion,
"headers" to response.message.headers,
"trailers" to response.message.trailers,
"method" to (response.message.method ?: "<unknown>"),
"url" to (response.message.url ?: "<unknown>"),
"statusCode" to (response.message.statusCode ?: "<unknown>"),
"statusMessage" to (response.message.statusMessage ?: "<unknown>"),
"body" to response.readBody().await()
),
space = 2
)
debug("Response:\n$responseMessage")
}
error("Could not determine download URL (statusCode: ${response.message.statusCode} / statusMessage: ${response.message.statusMessage})")
}

Expand Down

0 comments on commit a5e8694

Please sign in to comment.