Created
December 20, 2012 12:36
-
-
Save viktorklang/4345065 to your computer and use it in GitHub Desktop.
When NoStackTrace is one StackTrace too short
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
/** | |
* 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