Skip to content

Commit

Permalink
Update DevelopmentHandler.php
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Oct 28, 2024
1 parent b042987 commit 2d97aa1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/mako/error/handlers/cli/DevelopmentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
use Throwable;

use function array_keys;
use function array_map;
use function explode;
use function getcwd;
use function implode;
use function in_array;
use function str_replace;

/**
* Development handler.
Expand Down Expand Up @@ -80,19 +85,23 @@ public function handle(Throwable $exception): mixed
Alert::DANGER
);

$info = "<red><bold>{$this->escape($exception->getMessage())}</bold></red>";
$info = " <red><bold>{$this->escape($exception->getMessage())}</bold></red>";

$cwd = getcwd();

if (!empty($exception->getFile())) {
$info .= PHP_EOL
. PHP_EOL
. "The error occured in <bold>{$this->escape($exception->getFile())}</bold>"
. " The error occured in <bold>{$this->escape(str_replace($cwd, '.', $exception->getFile()))}</bold>"
. " on line <bold>{$exception->getLine()}</bold>"
. PHP_EOL;
}

$trace = $this->escape($exception->getTraceAsString());
$trace = $this->escape(
implode(PHP_EOL, array_map(fn ($str) => str_replace($cwd, '.', " {$str}"), explode(PHP_EOL, $exception->getTraceAsString())))
);

$this->output->errorLn($alert . PHP_EOL . $info . PHP_EOL . $trace);
$this->output->errorLn($alert . PHP_EOL . $info . PHP_EOL . $trace . PHP_EOL);

return false;
}
Expand Down

0 comments on commit 2d97aa1

Please sign in to comment.