besom
besom copied to clipboard
Improve compile error message for values that cannot be exported
Currently for types that do not have an instance of Encoder[A] compile error for exports function looks like this:
Compiling project (Scala 3.3.1, JVM (11))
[error] ./Main.scala:113:22
[error] Encoder[os.Path] is missing
[error] kubeconfigPath = os.pwd / "kubeconfig.conf"
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error compiling project (Scala 3.3.1, JVM (11))
Compilation failed
for code:
yield exports(
leaderIp = leaderIp,
kubeconfigPath = os.pwd / "kubeconfig.conf"
)
We should improve the error message here and explain what's going on. Maybe even offer public Encoder access with contravariant combinator?
This happens in Exports.scala:24-56, applyDynamicNamedImpl macro method scope. Precise location Exports.scala:39 but it gets called on line 44.
The workaround is to convert your type here to something that has an obvious Encoder instance like any numeric type, Strings and spray.json JSON AST values.