Skip to content

Commit

Permalink
Merge pull request #69 from KacperFKorban/master
Browse files Browse the repository at this point in the history
Make 'wrong focus shape' error display readable code
  • Loading branch information
adamw authored Jun 2, 2021
2 parents c2fd335 + 06baf4b commit d5b3248
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object QuicklensMacros {
def modifyImpl[S, A](obj: Expr[S], focus: Expr[S => A])(using Quotes, Type[S], Type[A]): Expr[PathModify[S, A]] = {
import quotes.reflect.*

def unsupportedShapeInfo(tree: Tree) = s"Unsupported path element. Path must have shape: _.field1.field2.each.field3.(...), got: $tree"
def unsupportedShapeInfo(tree: Tree) = s"Unsupported path element. Path must have shape: _.field1.field2.each.field3.(...), got: ${tree.show}"

def methodSupported(method: String) =
Seq("at", "each", "eachWhere", "eachRight", "eachLeft", "atOrElse", "index", "when").contains(method)
Expand Down Expand Up @@ -69,7 +69,7 @@ object QuicklensMacros {
case i: Ident if i.name.startsWith("_") =>
Seq.empty
case _ =>
report.throwError(unsupportedShapeInfo(tree))
report.throwError(unsupportedShapeInfo(focus.asTerm))
}
}

Expand Down

0 comments on commit d5b3248

Please sign in to comment.