Throw Custom Exception

Solution 1:

You're not throwing an exception, but the class of an exception (just read the compiler error message...). You have to throw an exception instance.

case x:Exception => throw new CustomException("whatever")

Solution 2:

It would also be helpful to change your Exception class definition as follows:

case class customException(smth:String)  extends Exception(smth)