Skip to content

Commit

Permalink
Add ParseException
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor committed Aug 2, 2023
1 parent ef2a620 commit 9d81d79
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package com.buenaflor.kflogger.parser
* This class is immutable and thread safe (and any subclasses must also be so).
*/
public expect class KDefaultPrintfMessageParser private constructor() : KPrintfMessageParser {
@Throws(KParseException::class)
override fun parsePrintfTerm(
builder: KMessageBuilder<*>?,
index: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public expect abstract class KMessageParser() {
* Implementations of this method are required to invoke the [MessageBuilder.addParameterImpl]
* method of the supplied builder once for each parameter place-holder in the message.
*/
// TODO KFlogger : @Throws(com.buenaflor.kflogger.parser.ParseException::class)
@Throws(KParseException::class)
protected abstract fun <T> parseImpl(builder: KMessageBuilder<T>?)

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.buenaflor.kflogger.parser

public expect class KParseException : RuntimeException
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public expect abstract class KPrintfMessageParser() : KMessageParser {
* @param formatStart the index of the (first) format character in the term.
* @return the index after the last character of the term.
*/
@Throws(KParseException::class)
protected abstract fun parsePrintfTerm(
builder: KMessageBuilder<*>?,
index: Int,
Expand All @@ -55,9 +56,10 @@ public expect abstract class KPrintfMessageParser() : KMessageParser {
formatStart: Int
): Int

final override fun unescape(out: StringBuilder?, message: String?, start: Int, end: Int)
public final override fun unescape(out: StringBuilder?, message: String?, start: Int, end: Int)

final override fun <T> parseImpl(builder: KMessageBuilder<T>?)
@Throws(KParseException::class)
protected final override fun <T> parseImpl(builder: KMessageBuilder<T>?)

public companion object {
/**
Expand All @@ -71,6 +73,7 @@ public expect abstract class KPrintfMessageParser() : KMessageParser {
* found).
*/
// VisibleForTesting
@Throws(KParseException::class)
internal fun nextPrintfTerm(message: String, pos: Int): Int

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ class KPrintfMessageParserTest {
fun testNotCrashing() {
// This test is to ensure that the code compiles and does not crash.
messageParser.unescape(StringBuilder(), "", 0, 0)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public actual abstract class KMessageParser {
* Implementations of this method are required to invoke the [MessageBuilder.addParameterImpl]
* method of the supplied builder once for each parameter place-holder in the message.
*/
@Throws(KParseException::class)
protected actual abstract fun <T> parseImpl(builder: KMessageBuilder<T>?)

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.buenaflor.kflogger.parser

public actual class KParseException : RuntimeException()
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public actual abstract class KPrintfMessageParser : KMessageParser() {
* @param formatStart the index of the (first) format character in the term.
* @return the index after the last character of the term.
*/
@Throws(KParseException::class)
protected actual abstract fun parsePrintfTerm(
builder: KMessageBuilder<*>?,
index: Int,
Expand All @@ -59,6 +60,7 @@ public actual abstract class KPrintfMessageParser : KMessageParser() {
TODO()
}

@Throws(KParseException::class)
actual final override fun <T> parseImpl(builder: KMessageBuilder<T>?) {
TODO()
}
Expand All @@ -77,6 +79,7 @@ public actual abstract class KPrintfMessageParser : KMessageParser() {
* found).
*/
// VisibleForTesting
@Throws(KParseException::class)
internal actual fun nextPrintfTerm(message: String, pos: Int): Int {
TODO()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.buenaflor.kflogger.parser

public actual typealias KParseException = ParseException

0 comments on commit 9d81d79

Please sign in to comment.