diff --git a/core/src/main/scala-2/sttp/tapir/internal/MapToMacro.scala b/core/src/main/scala-2/sttp/tapir/internal/MapToMacro.scala index d1e28f1ec6..d8be23f276 100644 --- a/core/src/main/scala-2/sttp/tapir/internal/MapToMacro.scala +++ b/core/src/main/scala-2/sttp/tapir/internal/MapToMacro.scala @@ -85,14 +85,21 @@ private[tapir] object MapToMacro { ): Unit = { val tupleSymbol = tupleType.typeSymbol if (!tupleSymbol.fullName.startsWith("scala.Tuple") && caseClassUtil.fields.nonEmpty) { - c.abort(c.enclosingPosition, s"Expected source type to be a tuple, but got: $tupleType") + c.abort(c.enclosingPosition, s"Expected source type to be a tuple, but got: ${tupleType.dealias}") } if (caseClassUtil.fields.size != tupleTypeArgs.size) { - c.abort( - c.enclosingPosition, - s"The arity of the source type doesn't match the arity of the target type: $tupleType, ${caseClassUtil.t}" - ) + if (caseClassUtil.fields.size > 22) { + c.abort( + c.enclosingPosition, + s"Cannot map to ${caseClassUtil.t}: arities of up to 22 are supported. If you need more inputs/outputs, map them to classes with less fields, and then combine these classes." + ) + } else { + c.abort( + c.enclosingPosition, + s"The arity of the source type (${tupleTypeArgs.size}) doesn't match the arity of the target type (${caseClassUtil.fields.size}): ${tupleType.dealias}, ${caseClassUtil.t}" + ) + } } caseClassUtil.fields.zip(tupleTypeArgs).foreach { case (caseClassField, tupleArg) => diff --git a/core/src/main/scala-3/sttp/tapir/internal/ComplietimeErrors.scala b/core/src/main/scala-3/sttp/tapir/internal/ComplietimeErrors.scala index b8d81e14e8..a65ace1abb 100644 --- a/core/src/main/scala-3/sttp/tapir/internal/ComplietimeErrors.scala +++ b/core/src/main/scala-3/sttp/tapir/internal/ComplietimeErrors.scala @@ -10,7 +10,11 @@ private[tapir] object ComplietimeErrors { private def reportIncorrectMappingImpl[SOURCE: Type, TARGET: Type](using Quotes): Expr[Unit] = { import quotes.reflect.* - report.throwError(s"Failed to map ${Type.show[SOURCE]} into ${Type.show[TARGET]}") + if TypeRepr.of[TARGET].typeSymbol.declaredFields.size > 22 then + report.throwError( + s"Cannot map to ${Type.show[TARGET]}: arities of up to 22 are supported. If you need more inputs/outputs, map them to classes with less fields, and then combine these classes." + ) + else report.throwError(s"Failed to map ${Type.show[SOURCE]} into ${Type.show[TARGET]}") } }