Handle MiddlewareError gracefully

Do no nest the eceptions.

Ticket:	#6367