spells.StackTraceElementModule.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spells_2.11 Show documentation
Show all versions of spells_2.11 Show documentation
This is a small scala "util" library, which will hopefully grow over time.
The newest version!
package spells
/** Contains custom rendering for `StackTraceElement`. */
trait StackTraceElementModule {
this: CustomRenderingModule with StringOpsModule with SpellsConfigModule =>
implicit final class StackTraceElementOpsFromSpells(value: StackTraceElement) extends CustomRendering {
override final def rendered(implicit availableWidthInCharacters: StringOpsModule#AvailableWidthInCharacters = SpellsConfig.terminal.WidthInCharacters.value): String = {
val fileNameOrUnknownSource =
if (value.getFileName != null)
"(" + value.getFileName + ")"
else "(Unknown Source)"
val fileNameOrUnknownSourceWithLineNumber =
if (value.getFileName != null && value.getLineNumber >= 0)
"(" + value.getFileName + ":" + value.getLineNumber + ")"
else fileNameOrUnknownSource
val fileNameOrUnknownSourceWithLineNumberOrNativeMethod =
if (value.isNativeMethod)
"(Native Method)"
else fileNameOrUnknownSourceWithLineNumber
if (SpellsConfig.`custom-rendering`.display.ShortStackTraceElements.value)
fileNameOrUnknownSourceWithLineNumberOrNativeMethod
else value.getClassName + "." + value.getMethodName + fileNameOrUnknownSourceWithLineNumberOrNativeMethod
}
}
}