mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Improve enum exception message (#694)
* Improve enum exception message It is applicable to enums for proguard reasons, just not with code gen as well * Update test message
This commit is contained in:
@@ -73,7 +73,7 @@ internal data class TargetType(
|
|||||||
when {
|
when {
|
||||||
proto.classKind == Class.Kind.ENUM_CLASS -> {
|
proto.classKind == Class.Kind.ENUM_CLASS -> {
|
||||||
messager.printMessage(
|
messager.printMessage(
|
||||||
ERROR, "@JsonClass can't be applied to $element: must not be an enum class", element)
|
ERROR, "@JsonClass with 'generateAdapter = \"true\"' can't be applied to $element: code gen for enums is not supported or necessary", element)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
proto.classKind != Class.Kind.CLASS -> {
|
proto.classKind != Class.Kind.CLASS -> {
|
||||||
|
@@ -153,7 +153,7 @@ class JsonClassCodegenProcessorTest {
|
|||||||
val result = call.execute()
|
val result = call.execute()
|
||||||
assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR)
|
assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR)
|
||||||
assertThat(result.systemErr).contains(
|
assertThat(result.systemErr).contains(
|
||||||
"error: @JsonClass can't be applied to KotlinEnum: must not be an enum class")
|
"error: @JsonClass with 'generateAdapter = \"true\"' can't be applied to KotlinEnum: code gen for enums is not supported or necessary")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Annotation processors don't get called for local classes, so we don't have the opportunity to
|
// Annotation processors don't get called for local classes, so we don't have the opportunity to
|
||||||
|
Reference in New Issue
Block a user