How to Throw & Handle Scala Exceptions - Rollbar
rollbar.com › how-to-throw-handle-scala-exceptionsOct 21, 2021 · All exception and error types in Scala are subclasses of the Throwable class, the base class of the Scala exception hierarchy: Fig1: Scala Exceptions Hierarchy. As evident from the diagram shown above, one branch of the hierarchy under Throwable is headed by Exception, which is the class used for exceptional conditions that programs should catch. An example of an exception is NullPointerException. Another branch is Error, which is used by the Java Virtual Machine (JVM) to indicate errors ...
Custom Exception in scala - Stack Overflow
stackoverflow.com › questions › 38243530Apr 12, 2018 · case class CustomException(message: String) extends Exception(message) with MyException { override val details: JsValue = Json.obj("message" -> message, "etc" -> "Anything else") } Now, the whole point of using Scala is walking towards a more functional programming style, it will make your app more concurrent, so if you need to use your new custom exception, you might want to try something like this: