bugfix in exception handling middleware