Quote invalid strings in exception messages

This commit is contained in:
Ilya Gorbunov
2021-07-07 02:52:54 +03:00
committed by Space
parent 3f6e2be687
commit 0427eec20f
2 changed files with 8 additions and 4 deletions
+2 -2
View File
@@ -186,7 +186,7 @@ public value class Duration internal constructor(private val rawValue: Long) : C
public fun parse(value: String): Duration = try {
parseDuration(value, strictIso = false)
} catch (e: IllegalArgumentException) {
throw IllegalArgumentException("Invalid duration string format: $value", e.takeIf { it.message != null })
throw IllegalArgumentException("Invalid duration string format: '$value'.", e)
}
/**
@@ -198,7 +198,7 @@ public value class Duration internal constructor(private val rawValue: Long) : C
public fun parseIsoString(value: String): Duration = try {
parseDuration(value, strictIso = true)
} catch (e: IllegalArgumentException) {
throw IllegalArgumentException("Invalid ISO duration string format: $value", e.takeIf { it.message != null })
throw IllegalArgumentException("Invalid ISO duration string format: '$value'.", e)
}
/**