开发者

Call Super Constructor

开发者 https://www.devze.com 2023-03-20 18:27 出处:网络
I have a custom exception class like the following : case class CustomException(errorMsg:String)extends Exception(error:String)

I have a custom exception class like the following :

case class CustomException(errorMsg:String)  extends Exception(error:String)

All what I need that when I catch exception is to throw my custom exception and pass my er开发者_如何学编程ror message to the custom exception . I expect from CustomException constructor to call super(errMsg) However , this isn't what goes now and I got a compilation error .

 catch {
      case s: Exception => throw CustomException("This is a custom message")
    }

How could I call the super constructor :

super(errorMessage)


case class CustomException(errorMsg:String)  extends Exception(errorMsg)


case class CustomException(errorMsg:String)  extends Exception(errorMsg)

You're calling the superclass's constructor, but the argument you are passing (error) isn't bound to anything.

0

精彩评论

暂无评论...
验证码 换一张
取 消