Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Config/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ class Exceptions extends BaseConfig
*/
public array $sensitiveDataInTrace = [];

/**
* Query, form, and cookie names whose values may be shown in the detailed HTML error page.
*
* Built-in and configured redaction rules still apply to allowed values.
*
* @var array{
* query?: list<string>,
* form?: list<string>,
* cookies?: list<string>
* }
*/
public array $diagnosticValues = [];

/**
* --------------------------------------------------------------------------
* WHETHER TO THROW AN EXCEPTION ON DEPRECATED ERRORS
Expand Down
16 changes: 16 additions & 0 deletions app/Config/Kint.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ class Kint
public bool $displayCalledFrom = true;
public bool $expanded = false;

/**
* Editor URL template using %f for the absolute filename and %l for the line.
* Leave null to use the Xdebug setting.
*
* Common templates:
* - VS Code: 'vscode://file%f:%l'
* - Cursor: 'cursor://file%f:%l'
* - PhpStorm: 'phpstorm://open?file=%f&line=%l'
* - IntelliJ IDEA: 'idea://open?file=%f&line=%l'
* - Sublime Text: 'subl://open?url=file://%f&line=%l'
* - TextMate: 'txmt://open?url=file://%f&line=%l'
*
* @var non-empty-string|null
*/
public ?string $fileLinkFormat = null;

/*
|--------------------------------------------------------------------------
| RichRenderer Settings
Expand Down
73 changes: 11 additions & 62 deletions app/Views/errors/cli/error_exception.php
Original file line number Diff line number Diff line change
@@ -1,65 +1,14 @@
<?php

use CodeIgniter\CLI\CLI;

// The main Exception
CLI::write('[' . $exception::class . ']', 'light_gray', 'red');
CLI::write($message);
CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green'));
CLI::newLine();

$last = $exception;

while ($prevException = $last->getPrevious()) {
$last = $prevException;

CLI::write(' Caused by:');
CLI::write(' [' . $prevException::class . ']', 'red');
CLI::write(' ' . $prevException->getMessage());
CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green'));
CLI::newLine();
}

// The backtrace
if ((defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) || CLI::getOutput()->isVerbose()) {
$backtraces = $last->getTrace();

if ($backtraces) {
CLI::write('Backtrace:', 'green');
}

foreach ($backtraces as $i => $error) {
$padFile = ' '; // 4 spaces
$padClass = ' '; // 7 spaces
$c = str_pad($i + 1, 3, ' ', STR_PAD_LEFT);
declare(strict_types=1);

if (isset($error['file'])) {
$filepath = clean_path($error['file']) . ':' . $error['line'];

CLI::write($c . $padFile . CLI::color($filepath, 'yellow'));
} else {
CLI::write($c . $padFile . CLI::color('[internal function]', 'yellow'));
}

$function = '';

if (isset($error['class'])) {
$type = ($error['type'] === '->') ? '()' . $error['type'] : $error['type'];
$function .= $padClass . $error['class'] . $type . $error['function'];
} elseif (! isset($error['class']) && isset($error['function'])) {
$function .= $padClass . $error['function'];
}

$args = implode(', ', array_map(static fn ($value): string => match (true) {
is_object($value) => 'Object(' . $value::class . ')',
is_array($value) => $value !== [] ? '[...]' : '[]',
$value === null => 'null', // return the lowercased version
default => var_export($value, true),
}, array_values($error['args'] ?? [])));

$function .= '(' . $args . ')';

CLI::write($function);
CLI::newLine();
}
}
use CodeIgniter\CLI\CLI;
use CodeIgniter\Debug\ConsoleExceptionRenderer;
use Config\Exceptions;

/**
* @var Exceptions $config
* @var Throwable $exception
* @var string $message
*/
ConsoleExceptionRenderer::render($exception, $message, CLI::getOutput(), $config->sensitiveDataInTrace);
77 changes: 0 additions & 77 deletions app/Views/errors/html/debug.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,9 @@ p.lead {
.header .container {
padding: 1rem;
}
.header-title {
align-items: flex-start;
display: flex;
gap: 1rem;
justify-content: space-between;
}
.header h1 {
font-size: 2.5rem;
font-weight: 500;
min-width: 0;
}
.header p {
font-size: 1.2rem;
Expand All @@ -72,58 +65,8 @@ p.lead {
display: inline;
}

.error-report {
flex: 0 0 auto;
margin-top: 0.35rem;
}

.error-report-button {
align-items: center;
background: rgba(255,255,255,0.35);
border: 1px solid rgba(0,0,0,0.14);
border-radius: 5px;
box-sizing: border-box;
color: var(--main-text-color);
cursor: pointer;
display: inline-flex;
font-size: 0.82rem;
font-weight: 500;
gap: 0.35rem;
height: 1.875rem;
justify-content: center;
line-height: 1;
padding: 0 0.65rem;
transition: background-color 160ms ease-in-out, border-color 160ms ease-in-out, color 160ms ease-in-out, box-shadow 160ms ease-in-out;
white-space: nowrap;
width: 7.15rem;
}

.error-report-button:hover {
background: rgba(255,255,255,0.6);
border-color: rgba(0,0,0,0.22);
color: var(--dark-text-color);
box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.error-report-button:focus-visible {
border-color: rgba(0,0,0,0.35);
outline: 0;
box-shadow: 0 0 0 2px rgba(220,72,20,0.16);
}

.error-report-button:active {
background: rgba(255,255,255,0.75);
}

.error-report-icon {
flex: 0 0 auto;
height: 0.72rem;
width: 0.72rem;
}

.environment {
background: var(--brand-primary-color);
box-sizing: border-box;
color: var(--main-bg-color);
text-align: center;
padding: calc(4px + 0.2083vw);
Expand All @@ -132,26 +75,6 @@ p.lead {
position: fixed;
}

@media (max-width: 40rem) {
.header {
margin-top: 0;
}

.header p {
font-size: 1.1rem;
line-height: 1.45;
margin-top: 0.35rem;
overflow-wrap: anywhere;
}

.environment {
font-size: 0.9rem;
line-height: 1.25;
padding: 0.45rem 0.75rem;
position: static;
}
}

.source {
background: #343434;
color: var(--light-text-color);
Expand Down
26 changes: 0 additions & 26 deletions app/Views/errors/html/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,3 @@ function toggle(elem)

return false;
}

function copyErrorReport(reportId, button)
{
if (! navigator.clipboard || ! window.isSecureContext)
{
return false;
}

var report = document.getElementById(reportId);
navigator.clipboard.writeText(report.value).then(function () {
showCopiedButton(button);
});

return false;
}

function showCopiedButton(button)
{
button.defaultHtml = button.defaultHtml || button.innerHTML;
button.innerHTML = 'Copied!';

window.clearTimeout(button.copyResetTimer);
button.copyResetTimer = window.setTimeout(function () {
button.innerHTML = button.defaultHtml;
}, 1500);
}
Loading
Loading