When a type X contains non-serializable types in its parameters, MessageCodec.of[X].toXXX will throw a runtime exception.
For the application safety, we should be able to check whether the type is serializable or not when creating a codec:
case class X(p:Y)
case class Y(a:NonSerializableType)
val codec = MessageCodec.of[X] // Throw NonSerializable exception (e.g., "Y.a" is not serializable)
When a type X contains non-serializable types in its parameters, MessageCodec.of[X].toXXX will throw a runtime exception.
For the application safety, we should be able to check whether the type is serializable or not when creating a codec: