Skip to content

Commit

Permalink
Merge pull request #27 from DareFox/kotlin
Browse files Browse the repository at this point in the history
refactor: Show error code on unsuccessful HLTB index page access
  • Loading branch information
DareFox authored Dec 9, 2024
2 parents ef78d35 + 192a28b commit 7959828
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/kotlin/io/github/darefox/hltbproxy/hltb/HLTB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ object HLTB {
log.info("Updating key...")
keyMutex.withLock { // keyMutex needed for API calls to wait new key
val url = "https://howlongtobeat.com"
val response = client(Request(GET, url).hltbDefaultHeaders(url, false))
val request = Request(GET, url).hltbDefaultHeaders(url, false)
val response = client(request)

val bodyString = response.bodyString()
if (response.status != Status.OK) {
if (!response.status.successful) {
log.error { "Response is not ok, body: ${response.bodyString()}" }
error("Response is not 199 from HLTB server, can't get search key")
error("Can't get search key, HLTB server returned ${response.status.code}")
}

val html = Jsoup.parse(bodyString)
Expand Down

0 comments on commit 7959828

Please sign in to comment.