Skip to content

Instantly share code, notes, and snippets.

@j5ik2o
Created December 29, 2011 23:33
Show Gist options
  • Save j5ik2o/1536703 to your computer and use it in GitHub Desktop.
Save j5ik2o/1536703 to your computer and use it in GitHub Desktop.
例外を定義する便利なパターン
case class EntityNotFoundException(message: Option[String] = None, cause: Option[Throwable] = None)
extends Exception(message.orNull, cause.orNull)
@xuwei-k
Copy link

xuwei-k commented Dec 30, 2011

message.getOrElse(null)

message.orNull

と、微妙に短く書くこともできますよ| ω・`)

@j5ik2o
Copy link
Author

j5ik2o commented Dec 30, 2011

おお、なるほど。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment