Skip to content

Commit

Permalink
Make stack traces optional
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Sep 20, 2024
1 parent 7f7cb32 commit 344625f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/wisteria.VariantError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ import scala.deriving.*
import scala.compiletime.*

object VariantError:
inline def apply[DerivationType](inputLabel: Text)(using reflection: SumReflection[DerivationType])
inline def apply[DerivationType](inputLabel: Text)
(using reflection: SumReflection[DerivationType], diagnostics: Diagnostics)
: VariantError =

val variants = constValueTuple[reflection.MirroredElemLabels].toList.map(_.toString.tt)
val sum = constValue[reflection.MirroredLabel].tt

VariantError(inputLabel, sum, variants)

case class VariantError(inputLabel: Text, sum: Text, validVariants: List[Text])
extends Error(m"""the specified variant ($inputLabel) is not one of the valid variants
(${validVariants.mkString(", ").tt}) of sum type $sum""")
case class VariantError(inputLabel: Text, sum: Text, validVariants: List[Text])(using Diagnostics)
extends Error
(m"""the specified variant ($inputLabel) is not one of the valid variants
(${validVariants.mkString(", ").tt}) of sum type $sum""")

0 comments on commit 344625f

Please sign in to comment.