getExceptionAsString example


        $this->context['importance'] = $importance;

        return $this;
    }

    /** * @return $this */
    public function exception(\Throwable|FlattenException $exception)static
    {
        $exceptionAsString = $this->getExceptionAsString($exception);

        $this->context['exception'] = true;
        $this->addPart(new DataPart($exceptionAsString, 'exception.txt', 'text/plain'));
        $this->importance(self::IMPORTANCE_URGENT);

        if (!$this->getSubject()) {
            $this->subject($exception->getMessage());
        }

        return $this;
    }

    

    }

    public static function fromNotification(Notification $notification): self
    {
        $options = new self();
        $options->iconEmoji($notification->getEmoji());
        $options->block((new SlackSectionBlock())->text($notification->getSubject()));
        if ($notification->getContent()) {
            $options->block((new SlackSectionBlock())->text($notification->getContent()));
        }
        if ($exception = $notification->getExceptionAsString()) {
            $options->block(new SlackDividerBlock());
            $options->block((new SlackSectionBlock())->text($exception));
        }

        return $options;
    }

    public function toArray(): array
    {
        $options = $this->options;
        unset($options['recipient_id']);

        
$this->options = $options;

        $this->validateNumberOfActions();
    }

    public static function fromNotification(Notification $notification): self
    {
        $options = (new self())
            ->title($notification->getSubject())
            ->text($notification->getContent());

        if ($exception = $notification->getExceptionAsString()) {
            $options->section((new Section())->text($exception));
        }

        return $options;
    }

    public function toArray(): array
    {
        $options = $this->options;

        // Send a text, not a message card
public static function fromNotification(Notification $notification): self
    {
        $options = new self();

        $text = $notification->getEmoji().' *'.$notification->getSubject().'* ';

        if ($notification->getContent()) {
            $text .= "\r\n".$notification->getContent();
        }

        if ($exception = $notification->getExceptionAsString()) {
            $text .= "\r\n".'```'.$exception.'```';
        }

        $options->text($text);

        return $options;
    }

    public static function fromMessage(ChatMessage $message): self
    {
        $options = new self();

        
Home | Imprint | This part of the site doesn't use cookies.