All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scala.quoted.runtime.impl.ExprCastException.scala Maven / Gradle / Ivy

There is a newer version: 3.6.4-RC1-bin-20241220-0bfa1af-NIGHTLY
Show newest version
package scala.quoted.runtime.impl

import dotty.tools.dotc.ast.tpd.Tree
import dotty.tools.dotc.core.Contexts.*

class ExprCastException(msg: String) extends Exception(msg)


object ExprCastException:
  def apply(expectedType: String, actualType: String, exprCode: String): ExprCastException =
    new ExprCastException(
      s"""|
          |  Expected type: ${formatLines(expectedType)}
          |  Actual type: ${formatLines(actualType)}
          |  Expression: ${formatLines(exprCode)}
          |""".stripMargin)

  private def formatLines(str: String): String =
    if !str.contains("\n") then str
    else str.linesIterator.mkString("\n    ", "\n    ", "\n")




© 2015 - 2025 Weber Informatics LLC | Privacy Policy