Convert error-stack into library object

Conver the error-stack visualization from an effectively-standalone
procedural routine into a library object which can be used to generate
error stacks from various input sources and for various output
encodings.