added exception tracing middleware for debugging