verifyWithSigning($request); $handler = $this->determineHandler(); try { $response = $handler->handle($this->request); } catch (SlackSlashCommandException $exception) { $response = $exception->getResponse($this->request); } catch (ValidationException $exception) { $response = $this->prepareValidationResponse($exception); } catch (Exception $exception) { $response = $this->convertToResponse($exception); } return $response->getIlluminateResponse(); } protected function prepareValidationResponse(ValidationException $exception): Response { $errors = (new Collection($exception->errors())) ->map( fn(array $message): Attachment => Attachment::create() ->setColor("danger") ->setText($message[0]), ); return Response::create($this->request) ->withText(":x: Polecenie `/{$this->request->command} {$this->request->text}` jest niepoprawne:") ->withAttachments($errors->all()); } }