In java exceptions have at least these four constructors:
Exception()
Exception(String message)
Exception(String message, Throwable cause)
Exception(Throwable cause)
If you want to define your own extensions, you just have to declare a descendent exceptions and implement each desired constructor calling the corresponden super constructor
How can you achieve the same thing in scala?
so far now I saw this article and this SO answer, but I suspect there must be an easier way to achieve such a common thing
Default value for
causeis null. And formessageit is eithercause.toString()or null:So you can just use default values: