Skip to content

Commit b66824e

Browse files
committed
more error message improvements
1 parent 8a9bc6f commit b66824e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

commons-macros/src/main/scala/com/avsystem/commons/macros/rpc/RpcMappings.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait RpcMappings { this: RpcMacroCommons with RpcSymbols =>
1111
import c.universe._
1212

1313
def collectMethodMappings[Raw <: TagMatchingSymbol with AritySymbol, M](
14-
rawSymbols: List[Raw], rawShortDesc: String, realMethods: List[RealMethod])(
14+
rawSymbols: List[Raw], errorBase: String, realMethods: List[RealMethod])(
1515
createMapping: (Raw, MatchedMethod) => Res[M]): List[M] = {
1616

1717
val failedReals = new ListBuffer[String]
@@ -31,7 +31,7 @@ trait RpcMappings { this: RpcMacroCommons with RpcSymbols =>
3131
val unmatchedReport = errors.map { case (raw, err) =>
3232
s" * ${raw.shortDescription} ${raw.nameStr} did not match: ${indent(err, " ")}"
3333
}.mkString("\n")
34-
s"it has no matching $rawShortDesc:\n$unmatchedReport"
34+
s"$errorBase:\n$unmatchedReport"
3535
} match {
3636
case Ok(v) => Some(v)
3737
case Fail(msg) =>
@@ -40,10 +40,6 @@ trait RpcMappings { this: RpcMacroCommons with RpcSymbols =>
4040
}
4141
}
4242

43-
if (failedReals.nonEmpty) {
44-
abort(s"Following real methods could not be mapped to $rawShortDesc: ${failedReals.mkString(",")}")
45-
}
46-
4743
result
4844
}
4945

@@ -307,8 +303,10 @@ trait RpcMappings { this: RpcMacroCommons with RpcSymbols =>
307303
} yield MethodMapping(matchedMethod, rawMethod, paramMappings, resultConv)
308304
}
309305

310-
lazy val methodMappings: List[MethodMapping] =
311-
collectMethodMappings(raw.rawMethods, "raw methods", real.realMethods)(mappingRes)
306+
lazy val methodMappings: List[MethodMapping] = {
307+
val errorBase = s"it has no matching raw methods in ${raw.description}"
308+
collectMethodMappings(raw.rawMethods, errorBase, real.realMethods)(mappingRes)
309+
}
312310

313311
def ensureUniqueRpcNames(): Unit =
314312
methodMappings.groupBy(_.matchedMethod.rpcName).foreach {

commons-macros/src/main/scala/com/avsystem/commons/macros/rpc/RpcMetadatas.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ trait RpcMetadatas extends MacroMetadatas { this: RpcMacroCommons with RpcSymbol
107107
def compositeConstructor(param: CompositeParam): MetadataConstructor =
108108
new RpcTraitMetadataConstructor(param.actualType, Some(param))
109109

110-
def methodMappings(rpc: RealRpcTrait): Map[MethodMetadataParam, List[MethodMetadataMapping]] =
111-
collectMethodMappings(methodMdParams, "metadata parameters", rpc.realMethods)(_.mappingFor(_)).groupBy(_.mdParam)
110+
def methodMappings(rpc: RealRpcTrait): Map[MethodMetadataParam, List[MethodMetadataMapping]] = {
111+
val errorBase = s"it has no matching metadata parameters in $description"
112+
collectMethodMappings(methodMdParams, errorBase, rpc.realMethods)(_.mappingFor(_)).groupBy(_.mdParam)
113+
}
112114

113115
def tryMaterializeFor(rpc: RealRpcTrait, methodMappings: Map[MethodMetadataParam, List[MethodMetadataMapping]]): Res[Tree] =
114116
tryMaterialize(MatchedRpcTrait(rpc)) { case mmp: MethodMetadataParam =>

0 commit comments

Comments
 (0)