/** * Detect and account for API response errors. */ protected function detectError(Response $response) { if ($response->getStatus() === Response::ERROR_VALIDATION) { $this->getController()->messenger()->addError('There was an error during validation'); } }