Skip to content

Commit

Permalink
Update Whoops error handler to v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
N3Cr0N committed Jun 23, 2019
1 parent 1fe42b1 commit 446f3fc
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 58 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"require": {
"php": ">=5.3.7",
"filp/whoops": "^2.3"
"filp/whoops": "^2.4"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@
},
{
"name": "filp/whoops",
"version": "2.3.1",
"version_normalized": "2.3.1.0",
"version": "2.4.0",
"version_normalized": "2.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
"reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7"
"reference": "1a1a1044ad00e285bd2825fac4c3a0443d90ad33"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/bc0fd11bc455cc20ee4b5edabc63ebbf859324c7",
"reference": "bc0fd11bc455cc20ee4b5edabc63ebbf859324c7",
"url": "https://api.github.com/repos/filp/whoops/zipball/1a1a1044ad00e285bd2825fac4c3a0443d90ad33",
"reference": "1a1a1044ad00e285bd2825fac4c3a0443d90ad33",
"shasum": ""
},
"require": {
Expand All @@ -83,7 +83,7 @@
"symfony/var-dumper": "Pretty print complex values better with var-dumper available",
"whoops/soap": "Formats errors as SOAP responses"
},
"time": "2018-10-23T09:00:00+00:00",
"time": "2019-06-23T09:00:00+00:00",
"type": "library",
"extra": {
"branch-alias": {
Expand Down Expand Up @@ -124,12 +124,12 @@
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/mikey179/vfsStream.git",
"url": "https://github.com/bovigo/vfsStream.git",
"reference": "fc0fe8f4d0b527254a2dc45f0c265567c881d07e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mikey179/vfsStream/zipball/fc0fe8f4d0b527254a2dc45f0c265567c881d07e",
"url": "https://api.github.com/repos/bovigo/vfsStream/zipball/fc0fe8f4d0b527254a2dc45f0c265567c881d07e",
"reference": "fc0fe8f4d0b527254a2dc45f0c265567c881d07e",
"shasum": ""
},
Expand Down Expand Up @@ -825,7 +825,8 @@
"keywords": [
"mock",
"xunit"
]
],
"abandoned": true
},
{
"name": "psr/log",
Expand Down
8 changes: 8 additions & 0 deletions vendor/filp/whoops/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.4.0

* Allow to prepend and append handlers.

# 2.3.2

* Various fixes from the community.

# 2.3.1

* Prevent exception in Whoops when caught exception frame is not related to real file
Expand Down
6 changes: 5 additions & 1 deletion vendor/filp/whoops/src/Whoops/Exception/Frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public function getFileContents()
return null;
}

$this->fileContentsCache = file_get_contents($filePath);
try {
$this->fileContentsCache = file_get_contents($filePath);
} catch (ErrorException $exception) {
// Internal file paths of PHP extensions cannot be opened
}
}

return $this->fileContentsCache;
Expand Down
2 changes: 1 addition & 1 deletion vendor/filp/whoops/src/Whoops/Exception/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ protected function getTrace($e)
}

if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
return [];
return $traces;
}

// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
Expand Down
56 changes: 48 additions & 8 deletions vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class PlainTextHandler extends Handler
*/
private $traceFunctionArgsOutputLimit = 1024;

/**
* @var bool
*/
private $addPreviousToOutput = true;

/**
* @var bool
*/
Expand Down Expand Up @@ -114,6 +119,21 @@ public function addTraceToOutput($addTraceToOutput = null)
return $this;
}

/**
* Add previous exceptions to output.
* @param bool|null $addPreviousToOutput
* @return bool|$this
*/
public function addPreviousToOutput($addPreviousToOutput = null)
{
if (func_num_args() == 0) {
return $this->addPreviousToOutput;
}

$this->addPreviousToOutput = (bool) $addPreviousToOutput;
return $this;
}

/**
* Add error trace function arguments to output.
* Set to True for all frame args, or integer for the n first frame args.
Expand Down Expand Up @@ -151,14 +171,18 @@ public function setTraceFunctionArgsOutputLimit($traceFunctionArgsOutputLimit)
public function generateResponse()
{
$exception = $this->getException();
return sprintf(
"%s: %s in file %s on line %d%s\n",
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$this->getTraceOutput()
);
$message = $this->getExceptionOutput($exception);

if ($this->addPreviousToOutput) {
$previous = $exception->getPrevious();
while ($previous) {
$message .= "\n\nCaused by\n" . $this->getExceptionOutput($previous);
$previous = $previous->getPrevious();
}
}


return $message . $this->getTraceOutput() . "\n";
}

/**
Expand Down Expand Up @@ -284,6 +308,22 @@ private function getTraceOutput()
return $response;
}

/**
* Get the exception as plain text.
* @param \Throwable $exception
* @return string
*/
private function getExceptionOutput($exception)
{
return sprintf(
"%s: %s in file %s on line %d",
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine()
);
}

/**
* @return int
*/
Expand Down
5 changes: 3 additions & 2 deletions vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class PrettyPageHandler extends Handler
"idea" => "idea://open?file=%file&line=%line",
"vscode" => "vscode://file/%file:%line",
"atom" => "atom://core/open/file?filename=%file&line=%line",
"espresso" => "x-espresso://open?filepath=%file&lines=%line",
];

/**
Expand Down Expand Up @@ -391,7 +392,7 @@ public function handleUnconditionally($value = null)
* return "http://stackoverflow.com";
* });
* @param string $identifier
* @param string $resolver
* @param string|callable $resolver
*/
public function addEditor($identifier, $resolver)
{
Expand Down Expand Up @@ -704,7 +705,7 @@ private function masked(array $superGlobal, $superGlobalName)

$values = $superGlobal;
foreach ($blacklisted as $key) {
if (isset($superGlobal[$key])) {
if (isset($superGlobal[$key]) && is_string($superGlobal[$key])) {
$values[$key] = str_repeat('*', strlen($superGlobal[$key]));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function handle()
),
];

echo $this->toXml($response);
echo self::toXml($response);

return Handler::QUIT;
}
Expand Down
12 changes: 7 additions & 5 deletions vendor/filp/whoops/src/Whoops/Resources/css/whoops.base.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ body {
text-decoration: none;
}

.Whoops.container {
position: relative;
z-index: 9999999999;
}

.panel {
overflow-y: scroll;
height: 100%;
Expand Down Expand Up @@ -414,12 +419,9 @@ pre:not(.prettyprinted) {
display: none;
}

#copy-button {
.rightButton {
cursor: pointer;
border: 0;
}

.clipboard {
opacity: .8;
background: none;

Expand All @@ -431,7 +433,7 @@ pre:not(.prettyprinted) {
outline: none !important;
}

.clipboard:hover {
.rightButton:hover {
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
color: rgba(255, 255, 255, 0.3);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<div class="frames-description <?php echo $has_frames_tabs ? 'frames-description-application' : '' ?>">
<?php if ($has_frames_tabs): ?>
<?php if ($active_frames_tab == 'application'): ?>
<span href="#" id="application-frames-tab" class="frames-tab frames-tab-active">
<a href="#" id="application-frames-tab" class="frames-tab <?php echo $active_frames_tab == 'application' ? 'frames-tab-active' : '' ?>">
Application frames (<?php echo $frames->countIsApplication() ?>)
</span>
<?php else: ?>
<a href="#" id="application-frames-tab" class="frames-tab">
Application frames (<?php echo $frames->countIsApplication() ?>)
</a>
<?php endif; ?>
</a>
<a href="#" id="all-frames-tab" class="frames-tab <?php echo $active_frames_tab == 'all' ? 'frames-tab-active' : '' ?>">
All frames (<?php echo count($frames) ?>)
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@
</ul>

<span id="plain-exception"><?php echo $tpl->escape($plain_exception) ?></span>
<button id="copy-button" class="clipboard" data-clipboard-text="<?php echo $tpl->escape($plain_exception) ?>" title="Copy exception details to clipboard">
<button id="copy-button" class="rightButton clipboard" data-clipboard-text="<?php echo $tpl->escape($plain_exception) ?>" title="Copy exception details to clipboard">
COPY
</button>
<button id="hide-error" class="rightButton" title="Hide error message" onclick="document.getElementsByClassName('Whoops')[0].style.display = 'none';">
HIDE
</button>
</div>
</div>
Loading

0 comments on commit 446f3fc

Please sign in to comment.