error middleware, closes #60