Minor cleanups

This commit is contained in:
Erik C. Thauvin 2024-01-31 18:05:32 -08:00
parent 89b51307b3
commit 1a3c7fbac2
3 changed files with 11 additions and 20 deletions

View file

@ -45,6 +45,9 @@ import java.util.stream.Collectors
object JokeApi {
private const val API_URL = "https://v2.jokeapi.dev/"
/**
* The logger instance.
*/
@JvmStatic
val logger: Logger by lazy { Logger.getLogger(JokeApi::class.java.simpleName) }

View file

@ -123,6 +123,9 @@ private fun httpError(responseCode: Int): HttpErrorException {
return httpException
}
/**
* Parse Error.
*/
internal fun parseError(json: JSONObject): JokeException {
val causedBy = json.getJSONArray("causedBy")
val causes = List<String>(causedBy.length()) { i -> causedBy.getString(i) }
@ -136,6 +139,9 @@ internal fun parseError(json: JSONObject): JokeException {
)
}
/**
* Parse Joke.
*/
internal fun parseJoke(json: JSONObject, splitNewLine: Boolean): Joke {
val jokes = mutableListOf<String>()
if (json.has("setup")) {