Logo

Programming-Idioms

  • JS
  • Ruby
  • Python
  • Go
  • Elixir

Idiom #253 Print stack trace

Print the stack frames of the current execution thread of the program.

import "runtime/debug"
debug.PrintStack()

Prints to standard error
console.trace()
puts caller
import inspect
for frame in inspect.stack():
    print(frame)
import GHC.Stack
msgStacktraced :: HasCallStack => String -> IO ()
msgStacktraced msg = putStrLn (msg ++ "\n" ++ prettyCallStack callStack)

New implementation...
< >
programming-idioms.org