Simplify error handling

Use a common error handler struct appHandler which contains the common
JSON error handling code. Embed the handler instances. This simplfies
the error handling path.
@see http://elithrar.github.io/article/custom-handlers-avoiding-globals/