refactor: enhance error reporting and logging, add installer script
- Update `LogReporter` and `Reporter` interface to handle `Throwable` instead of `string` - Simplify initializer discovery message in `ClassNotInstantiable` exceptions - Remove unnecessary debug logs in `HttpRouter` - Add `scripts/install-aliases.sh` for setting up console aliases - Add minimal `console` script for Docker execution
This commit is contained in:
@@ -65,8 +65,16 @@ final class ClassNotInstantiable extends ContainerException
|
||||
}
|
||||
|
||||
if (!empty($this->discoveredInitializers)) {
|
||||
|
||||
$initializers = [];
|
||||
foreach($this->discoveredInitializers as $initializer) {
|
||||
$array = explode('\\', $initializer);
|
||||
$initializers[] = end($array);
|
||||
}
|
||||
|
||||
|
||||
$message .= "Discovered initializers (" . count($this->discoveredInitializers) . "): " .
|
||||
implode(', ', $this->discoveredInitializers) . "\n";
|
||||
implode(', ', $initializers) . "\n";
|
||||
} else {
|
||||
$message .= "No initializers discovered in DiscoveryRegistry.\n";
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ final readonly class ErrorKernel
|
||||
{
|
||||
|
||||
$log = new LogReporter();
|
||||
$log->report($e->getMessage());
|
||||
$log->report($e);
|
||||
|
||||
var_dump((string)$e);
|
||||
|
||||
|
||||
@@ -5,8 +5,22 @@ namespace App\Framework\ExceptionHandling\Reporter;
|
||||
|
||||
final class LogReporter implements Reporter
|
||||
{
|
||||
public function report(string $message): void
|
||||
public function report(\Throwable $e): void
|
||||
{
|
||||
echo ("[log] " . $message);
|
||||
echo "<pre>\n";
|
||||
|
||||
echo $e->getMessage();
|
||||
|
||||
echo "\n";
|
||||
|
||||
echo $e->getFile().':'.$e->getLine();
|
||||
|
||||
echo "\n";
|
||||
echo "\n";
|
||||
|
||||
echo $e->getTraceAsString();
|
||||
|
||||
echo "</pre>\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ namespace App\Framework\ExceptionHandling\Reporter;
|
||||
|
||||
interface Reporter
|
||||
{
|
||||
public function report(string $message): void;
|
||||
public function report(\Throwable $e): void;
|
||||
}
|
||||
|
||||
@@ -28,17 +28,11 @@ final readonly class HttpRouter implements Router
|
||||
|
||||
$appUrl = $this->environment->getString(EnvKey::APP_URL);
|
||||
|
||||
error_log('APPURL: ' . $appUrl);
|
||||
error_log('HOST: ' . $host);
|
||||
|
||||
|
||||
$pos = stripos($appUrl, '://');
|
||||
if($pos !== false) {
|
||||
$appUrl = substr($appUrl,$pos + 3);
|
||||
}
|
||||
|
||||
error_log('APPURL CLEAN: ' . $appUrl);
|
||||
|
||||
$subdomain = Subdomain::tryFromHost($host, $appUrl) ?? '';
|
||||
$subdomain = (string)$subdomain;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user