Change record status: 
Project: 
Introduced in branch: 
10.1.x
Introduced in version: 
10.1.0
Description: 

In order to help remove all exit calls from core, form builder functions can no longer return a response.

Instead they should throw a \Drupal\Core\Form\EnforcedResponseException
Before

class SomeForm extends FormBase {
  // ...
  public function buildForm(array $form, FormStateInterface $formState) {
    if ($this->someCheckForARedirect()) {
      return new RedirectResponse('/foo/bar');
    }
    // .. 
  }
}

After

use Drupal\Core\Form\EnforcedResponseException;
use Drupal\Core\Url;

class SomeForm extends FormBase {
  // ...
  public function buildForm(array $form, FormStateInterface $formState) {
    if ($this->someCheckForARedirect()) {
      throw EnforcedResponseException::redirectToUrl(Url::fromRoute('some.route'));
    }
    // .. 
  }
}
Impacts: 
Module developers