Skip to content

Instantly share code, notes, and snippets.

@viktorklang
Created December 20, 2012 12:36
Show Gist options
  • Save viktorklang/4345065 to your computer and use it in GitHub Desktop.
Save viktorklang/4345065 to your computer and use it in GitHub Desktop.
When NoStackTrace is one StackTrace too short
/**
* Mix in this trait to suppress the StackTrace for the instance of the exception but not the cause,
* scala.util.control.NoStackTrace suppresses all the StackTraces.
*/
trait OnlyCauseStackTrace { self: Throwable ⇒
override def fillInStackTrace(): Throwable = {
setStackTrace(getCause match {
case null ⇒ Array.empty
case some ⇒ some.getStackTrace
})
this
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment