Add pretty printing of errors

Previously, error was output as an empty key (since iterating over an
error with `for .. in` is an empty loop).

Split stacks into arrays so that they are easily readable.