Created
March 25, 2014 09:38
-
-
Save mather/9758177 to your computer and use it in GitHub Desktop.
Scalaで例外を定義 ref: http://qiita.com/mather314/items/b36a8f2832f0851d3eb7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyException(message: String = null, cause: Throwable = null) extends RuntimeException(message, cause) { | |
def this(cause: Throwable) = this(Option(cause).map(_.toString).getOrElse(null), cause) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new MyException() | |
new MyException("msg") | |
new MyException(new Exception("hoge")) | |
new MyException("addtional message", new Exception("hoge")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new MyException(cause = new Exception("hoge")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment