Skip to content

Commit

Permalink
up: update some for error handler render exception
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 13, 2022
1 parent 40b4cc8 commit 7720ce7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Component/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function handle(Throwable $e): void
ERR;
$line = $e->getLine();
$file = $e->getFile();
$prev = $e->getPrevious();

$snippet = Highlighter::create()->snippet(file_get_contents($file), $line, 3, 3);
$message = sprintf(
Expand All @@ -94,7 +95,7 @@ public function handle(Throwable $e): void
$file,
$line, // __METHOD__,
$snippet,
$e->getTraceAsString()// \str_replace('):', '): -', $e->getTraceAsString())
$e->getTraceAsString() . ($prev ? "\n<comment>Previous:</comment> {$prev->getMessage()}\n" . $prev->getTraceAsString() : '')
);

if ($this->hideRootPath && ($rootPath = $this->rootPath)) {
Expand Down
36 changes: 33 additions & 3 deletions src/Concern/AbstractInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,37 @@ public function __toString(): string
* @return string
*/
public function toString(): string
{
return $this->getTokenString();
}

/**
* @param bool $escape
*
* @return string
*/
public function getTokenString(bool $escape = true): string
{
if (!$this->tokens) {
return '';
}

$tokens = array_map([$this, 'tokenEscape'], $this->tokens);
return implode(' ', $tokens);
if ($escape) {
$tokens = array_map([$this, 'tokenEscape'], $this->tokens);
return implode(' ', $tokens);
}

return implode(' ', $this->tokens);
}

/**
* @param bool $escape
*
* @return string
*/
public function getInputUri(bool $escape = true): string
{
return $this->getTokenString($escape);
}

/**
Expand Down Expand Up @@ -258,10 +282,16 @@ public function setCommand(string $command): void
}

/**
* @param bool $withBinName
*
* @return string
*/
public function getFullScript(): string
public function getFullScript(bool $withBinName = false): string
{
if ($withBinName) {
return $this->getBinName() . ' ' . $this->fullScript;
}

return $this->fullScript;
}

Expand Down

0 comments on commit 7720ce7

Please sign in to comment.