guard against unset headers in error handling