Skip to content

Commit

Permalink
Add more info to macro error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdziuban committed May 17, 2024
1 parent 1406c6d commit 8e1f084
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions upickle/implicits/src/upickle/implicits/MacrosCommon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ object MacrosCommon {
case keys @ (key :: _) if keys.length == sealedParents.length && keys.distinct.length == 1 => key
case keys =>
fail(
s"Type $typeName inherits from multiple parent types with different `@key` annotations:\n" +
s"Type $typeName inherits from multiple parent types with different discriminator keys:\n\n" +
s" parents: ${sealedParents.map(getName).sorted.mkString(", ")}\n" +
s" keys: ${keys.sorted.mkString(", ")}"
s" keys: ${keys.sorted.mkString(", ")}\n\n" +
"To resolve this, either remove the `@key` annotations from all parents of the type,\n" +
"or make sure all the parents pass the same value to `@key`"
)
}
}

0 comments on commit 8e1f084

Please sign in to comment.