Improved excepetions handling.

This commit is contained in:
Erik C. Thauvin 2021-05-02 14:13:12 -07:00
parent 2ff60e434c
commit 65c736cc23
2 changed files with 11 additions and 10 deletions

View file

@ -1,11 +1,9 @@
<?xml version="1.0" ?>
<?xml version='1.0' encoding='UTF-8'?>
<SmellBaseline>
<Blacklist timestamp="1531308331780"></Blacklist>
<Whitelist timestamp="1558928560207">
<ID>ComplexMethod:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: List&lt;Pair&lt;String, String&gt;&gt;): Boolean</ID>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>LongParameterList:PinboardPoster.kt$PinboardPoster$( url: String, description: String, extended: String = "", tags: String = "", dt: String = "", replace: Boolean = true, shared: Boolean = true, toRead: Boolean = false )</ID>
<ID>NestedBlockDepth:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: List&lt;Pair&lt;String, String&gt;&gt;): Boolean</ID>
<ID>ThrowsCount:PinboardPoster.kt$PinboardPoster$internal fun parseMethodResponse(method: String, response: String)</ID>
<ID>TooGenericExceptionCaught:PinboardPoster.kt$PinboardPoster$e: Exception</ID>
</Whitelist>
</SmellBaseline>
<ID>NestedBlockDepth:PinboardPoster.kt$PinboardPoster$private fun executeMethod(method: String, params: List&lt;Pair&lt;String, String>>): Boolean</ID>
<ID>ThrowsCount:PinboardPoster.kt$PinboardPoster$@Throws(IOException::class) internal fun parseMethodResponse(method: String, response: String)</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -205,6 +205,7 @@ open class PinboardPoster() {
return false
}
@Throws(IOException::class)
internal fun parseMethodResponse(method: String, response: String) {
val factory = DocumentBuilderFactory.newInstance().apply {
isValidating = false
@ -228,8 +229,10 @@ open class PinboardPoster() {
} else {
throw IOException("An error has occurred while executing $method.")
}
} catch (e: Exception) {
} catch (e: org.xml.sax.SAXException) {
throw IOException("Could not parse $method response.", e)
} catch (e: IllegalArgumentException) {
throw IOException("Invalid input source for $method response", e)
}
}