<?php

declare(strict_types=1);

namespace Apexl\Io\Logger\Whoops\Handlers;

use Apexl\Io\Logger\Traits\GetsSimpleTrace;
use Whoops\Handler\Handler;

class IoLoggerHandler extends Handler
{
    use GetsSimpleTrace;

    public function handle(): ?int
    {
        $exception = $this->getException();

        \Apexl\Io\Logger\logger('error')->error(
            $exception->getMessage(),
            ['trace' => $this->simpleTrace($exception->getTrace())]
        );

        return Handler::DONE;
    }
}
