add raise errors middleware