updated errordocument handling