Skip to content

Commit

Permalink
Add dots in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Dec 20, 2023
1 parent 7ec71ed commit c913cb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal enum class ResourceType(val typeName: String) {
fun fromString(str: String): ResourceType =
ResourceType.values()
.firstOrNull { it.typeName.equals(str, true) }
?: error("Unknown resource type: $str")
?: error("Unknown resource type: '$str'.")
}
}

Expand Down Expand Up @@ -45,7 +45,7 @@ private fun CodeBlock.Builder.addQualifiers(resourceItem: ResourceItem): CodeBlo

fun saveQualifier(className: ClassName, qualifier: String) {
qualifiersMap[className]?.let {
error("${resourceItem.path} contains repetitive qualifiers: $it and $qualifier")
error("${resourceItem.path} contains repetitive qualifiers: '$it' and '$qualifier'.")
}
qualifiersMap[className] = qualifier
}
Expand Down Expand Up @@ -75,7 +75,7 @@ private fun CodeBlock.Builder.addQualifiers(resourceItem: ResourceItem): CodeBlo
saveQualifier(regionQualifier, q)
}

else -> error("${resourceItem.path} contains unknown qualifier: $q")
else -> error("${resourceItem.path} contains unknown qualifier: '$q'.")
}
}
}
Expand All @@ -85,11 +85,11 @@ private fun CodeBlock.Builder.addQualifiers(resourceItem: ResourceItem): CodeBlo
qualifiersMap[regionQualifier]?.let { q ->
val lang = qualifiersMap[languageQualifier]
if (lang == null) {
error("Region qualifier must be used only with language\nFile: ${resourceItem.path}")
error("Region qualifier must be used only with language.\nFile: ${resourceItem.path}")
}
val langAndRegion = "$lang-$q"
if(!resourceItem.path.toString().contains("-$langAndRegion")) {
error("Region qualifier must be declared after language: '$langAndRegion'\nFile: ${resourceItem.path}")
error("Region qualifier must be declared after language: '$langAndRegion'.\nFile: ${resourceItem.path}")
}
add("%T(\"${q.takeLast(2)}\"), ", regionQualifier)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ResourcesTest : GradlePluginTestBase() {
file("expected/Res.kt")
)
check.logContains("""
Unknown resource type: ignored
Unknown resource type: 'ignored'.
""".trimIndent())
}

Expand All @@ -39,7 +39,7 @@ class ResourcesTest : GradlePluginTestBase() {

gradle("generateComposeResClass").checks {
check.logContains("""
contains unknown qualifier: ren
contains unknown qualifier: 'ren'.
""".trimIndent())
}

Expand All @@ -49,7 +49,7 @@ class ResourcesTest : GradlePluginTestBase() {

gradle("generateComposeResClass").checks {
check.logContains("""
Region qualifier must be declared after language: 'en-rUS'
Region qualifier must be declared after language: 'en-rUS'.
""".trimIndent())
}

Expand All @@ -59,7 +59,7 @@ class ResourcesTest : GradlePluginTestBase() {

gradle("generateComposeResClass").checks {
check.logContains("""
Region qualifier must be used only with language
Region qualifier must be used only with language.
""".trimIndent())
}

Expand All @@ -69,7 +69,7 @@ class ResourcesTest : GradlePluginTestBase() {

gradle("generateComposeResClass").checks {
check.logContains("""
contains repetitive qualifiers: en and fr
contains repetitive qualifiers: 'en' and 'fr'.
""".trimIndent())
}

Expand Down

0 comments on commit c913cb8

Please sign in to comment.