Scala error function deprecated. What is the alternative?
haskell, scala
Solution
You should use `sys.error` as mentioned in `deprecated` message.
@deprecated("Use `sys.error(message)` instead", "2.9.0")
You could run scala with `-deprecation` option to get this message:
scala> def t = error("t")
<console>:7: warning: method error in object Predef is deprecated: Use `sys.error(message)` instead
Problem
I am porting some Haskell code over into Scala. In Haskell I can use the error function. It seems at some point you could do this in Scala but the IDE is showing me that this is deprecated now. Here is the code: ``` def prime (n : Int) : Boolean = () match { case _ if n < 1 => error("not a positive integer") case _ if n == 1 => false case _ => ld (n) == n } ``` What do I use instead of the error function in Scala now?