Skip to content

Commit 7959828

Browse files
authored
Merge pull request #27 from DareFox/kotlin
refactor: Show error code on unsuccessful HLTB index page access
2 parents ef78d35 + 192a28b commit 7959828

File tree

1 file changed

+4
-3
lines changed
  • src/main/kotlin/io/github/darefox/hltbproxy/hltb

1 file changed

+4
-3
lines changed

src/main/kotlin/io/github/darefox/hltbproxy/hltb/HLTB.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ object HLTB {
9393
log.info("Updating key...")
9494
keyMutex.withLock { // keyMutex needed for API calls to wait new key
9595
val url = "https://howlongtobeat.com"
96-
val response = client(Request(GET, url).hltbDefaultHeaders(url, false))
96+
val request = Request(GET, url).hltbDefaultHeaders(url, false)
97+
val response = client(request)
9798

9899
val bodyString = response.bodyString()
99-
if (response.status != Status.OK) {
100+
if (!response.status.successful) {
100101
log.error { "Response is not ok, body: ${response.bodyString()}" }
101-
error("Response is not 199 from HLTB server, can't get search key")
102+
error("Can't get search key, HLTB server returned ${response.status.code}")
102103
}
103104

104105
val html = Jsoup.parse(bodyString)

0 commit comments

Comments
 (0)