Fixes Bug 913428 - Rework middleware exceptions, r=peterbe