commonMain.io.islandtime.parser.DateTimeParseException.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-metadata Show documentation
Show all versions of core-metadata Show documentation
A multiplatform library for working with dates and times
The newest version!
package io.islandtime.parser
import io.islandtime.DateTimeException
class DateTimeParseException(
message: String? = null,
val parsedString: String? = null,
val errorIndex: Int = 0,
cause: Throwable? = null
) : DateTimeException(message, cause)
internal inline fun throwParserFieldResolutionException(parsedText: String): Nothing {
val objectType = T::class.simpleName ?: "Unknown"
throw DateTimeParseException(
"The provided parser was unable to supply the fields needed to resolve an object of type '$objectType'",
parsedText
)
}
internal inline fun throwParserGroupResolutionException(
expectedCount: Int,
actualCount: Int,
parsedText: String
): Nothing {
val objectType = T::class.simpleName ?: "Unknown"
throw DateTimeParseException(
"The provided parser was unable resolve an object of type '$objectType'. Expected $expectedCount groups, got " +
"$actualCount.",
parsedText
)
}
internal inline fun List.expectingGroupCount(
expected: Int,
parsedText: String
): List {
if (size != expected) {
throwParserGroupResolutionException(2, size, parsedText)
}
return this
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy