Skip to content

Commit 7720ce7

Browse files
committed
up: update some for error handler render exception
1 parent 40b4cc8 commit 7720ce7

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/Component/ErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function handle(Throwable $e): void
8686
ERR;
8787
$line = $e->getLine();
8888
$file = $e->getFile();
89+
$prev = $e->getPrevious();
8990

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

100101
if ($this->hideRootPath && ($rootPath = $this->rootPath)) {

src/Concern/AbstractInput.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,37 @@ public function __toString(): string
104104
* @return string
105105
*/
106106
public function toString(): string
107+
{
108+
return $this->getTokenString();
109+
}
110+
111+
/**
112+
* @param bool $escape
113+
*
114+
* @return string
115+
*/
116+
public function getTokenString(bool $escape = true): string
107117
{
108118
if (!$this->tokens) {
109119
return '';
110120
}
111121

112-
$tokens = array_map([$this, 'tokenEscape'], $this->tokens);
113-
return implode(' ', $tokens);
122+
if ($escape) {
123+
$tokens = array_map([$this, 'tokenEscape'], $this->tokens);
124+
return implode(' ', $tokens);
125+
}
126+
127+
return implode(' ', $this->tokens);
128+
}
129+
130+
/**
131+
* @param bool $escape
132+
*
133+
* @return string
134+
*/
135+
public function getInputUri(bool $escape = true): string
136+
{
137+
return $this->getTokenString($escape);
114138
}
115139

116140
/**
@@ -258,10 +282,16 @@ public function setCommand(string $command): void
258282
}
259283

260284
/**
285+
* @param bool $withBinName
286+
*
261287
* @return string
262288
*/
263-
public function getFullScript(): string
289+
public function getFullScript(bool $withBinName = false): string
264290
{
291+
if ($withBinName) {
292+
return $this->getBinName() . ' ' . $this->fullScript;
293+
}
294+
265295
return $this->fullScript;
266296
}
267297

0 commit comments

Comments
 (0)