Fixes Bug 913428 - Rework middleware exceptions