mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Manage github API errors better.
This commit is contained in:
parent
3bf91feffe
commit
1efbabe6bd
1 changed files with 18 additions and 10 deletions
|
@ -6,6 +6,7 @@ import com.beust.kobalt.internal.KobaltSettings
|
|||
import com.beust.kobalt.maven.Http
|
||||
import com.beust.kobalt.maven.aether.Exceptions
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonParser
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.google.inject.Inject
|
||||
import okhttp3.OkHttpClient
|
||||
|
@ -119,7 +120,13 @@ class GithubApi2 @Inject constructor(
|
|||
} else {
|
||||
service.getReleasesNoAuth("cbeust", "kobalt")
|
||||
}
|
||||
val releases = req.execute().body()
|
||||
val ex = req.execute()
|
||||
val errorBody = ex.errorBody()
|
||||
if (errorBody != null) {
|
||||
val jsonError = JsonParser().parse(errorBody.string())
|
||||
warn("Couldn't call Github.getReleases(): $jsonError")
|
||||
} else {
|
||||
val releases = ex.body()
|
||||
if (releases != null) {
|
||||
releases.firstOrNull()?.let {
|
||||
try {
|
||||
|
@ -131,6 +138,7 @@ class GithubApi2 @Inject constructor(
|
|||
} else {
|
||||
warn("Didn't receive any body in the response to GitHub.getReleases()")
|
||||
}
|
||||
}
|
||||
} catch(e: Exception) {
|
||||
kobaltLog(1, "Couldn't retrieve releases from github: " + e.message)
|
||||
Exceptions.printStackTrace(e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue