Improve pretty exception middleware