Skip to content

Commit dfd090b

Browse files
committed
Refactor direct usages of throw QuoteError
1 parent 03df592 commit dfd090b

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

docs/docs/reference/other-new-features/tasty-reflect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def natConstImpl(x: Expr[Int])(implicit reflection: Reflection): Expr[Int] = {
4242
xTree match {
4343
case Term.Literal(Constant.Int(n)) =>
4444
if (n <= 0)
45-
throw new QuoteError("Parameter must be natural number")
45+
QuoteError("Parameter must be natural number")
4646
n.toExpr
4747
case _ =>
48-
throw new QuoteError("Parameter must be a known constant")
48+
QuoteError("Parameter must be a known constant")
4949
}
5050
}
5151
```

tests/run/f-interpolation-1/FQuote_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object FQuote {
3939
values.forall(isStringConstant) =>
4040
values.collect { case Term.Literal(Constant.String(value)) => value }
4141
case tree =>
42-
throw new QuoteError(s"String literal expected, but ${tree.show} found")
42+
QuoteError(s"String literal expected, but ${tree.show} found")
4343
}
4444

4545
// [a0, ...]: Any*

tests/run/tasty-interpolation-1/Macro.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ abstract class MacroStringInterpolator[T] {
3838
catch {
3939
case ex: NotStaticlyKnownError =>
4040
// TODO use ex.expr to recover the position
41-
throw new QuoteError(ex.getMessage)
41+
QuoteError(ex.getMessage)
4242
case ex: StringContextError =>
4343
// TODO use ex.idx to recover the position
44-
throw new QuoteError(ex.getMessage)
44+
QuoteError(ex.getMessage)
4545
case ex: ArgumentError =>
4646
// TODO use ex.idx to recover the position
47-
throw new QuoteError(ex.getMessage)
47+
QuoteError(ex.getMessage)
4848
}
4949
}
5050

tests/run/tasty-macro-const/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ object Macros {
1111
xTree match {
1212
case Term.Inlined(_, _, Term.Literal(Constant.Int(n))) =>
1313
if (n <= 0)
14-
throw new QuoteError("Parameter must be natural number")
14+
QuoteError("Parameter must be natural number")
1515
xTree.seal[Int]
1616
case _ =>
17-
throw new QuoteError("Parameter must be a known constant")
17+
QuoteError("Parameter must be a known constant")
1818
}
1919
}
2020

tests/run/xml-interpolation-1/XmlQuote_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object XmlQuote {
1717
import Term._
1818

1919
def abort(msg: String): Nothing =
20-
throw new QuoteError(msg)
20+
QuoteError(msg)
2121

2222
// for debugging purpose
2323
def pp(tree: Tree): Unit = {

0 commit comments

Comments
 (0)