Catch all IOExceptions in executeMethod. Closes #2

This commit is contained in:
Erik C. Thauvin 2020-08-19 16:41:45 -07:00
parent 505eee98f0
commit d3b6fb50d1

View file

@ -242,6 +242,7 @@ open class PinboardPoster() {
} }
private fun executeMethod(method: String, params: List<Pair<String, String>>): Boolean { private fun executeMethod(method: String, params: List<Pair<String, String>>): Boolean {
try {
val apiUrl = cleanEndPoint(method).toHttpUrlOrNull() val apiUrl = cleanEndPoint(method).toHttpUrlOrNull()
if (apiUrl != null) { if (apiUrl != null) {
val httpUrl = apiUrl.newBuilder().apply { val httpUrl = apiUrl.newBuilder().apply {
@ -259,16 +260,15 @@ open class PinboardPoster() {
if (response.contains("done")) { if (response.contains("done")) {
return true return true
} else { } else {
try {
parseMethodResponse(method, response) parseMethodResponse(method, response)
} catch (e: IOException) {
logger.log(Level.SEVERE, e.message, e)
}
} }
} }
} else { } else {
logger.severe("Invalid API end point: $apiEndPoint") logger.severe("Invalid API end point: $apiEndPoint")
} }
} catch (e: IOException) {
logger.log(Level.SEVERE, e.message, e)
}
return false return false
} }