🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 15:51
This commit is contained in:
@@ -70,18 +70,18 @@ final class Application
|
||||
try {
|
||||
$request = new Request();
|
||||
$this->router->dispatch($request, $this->container);
|
||||
} catch (\App\Core\Exceptions\HttpException $e) {
|
||||
// Application-level intentional HTTP errors
|
||||
Response::error($e->getMessage(), $e->getErrorCode(), $e->getCode(), $e->getData());
|
||||
} catch (\Throwable $e) {
|
||||
// Global Exception Handler
|
||||
Response::error(
|
||||
'حدث خطأ غير متوقع في النظام',
|
||||
'INTERNAL_SERVER_ERROR',
|
||||
500,
|
||||
[
|
||||
'message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine()
|
||||
]
|
||||
);
|
||||
// Log real error internally only
|
||||
error_log("[MUSADAQ_ERROR] " . $e->getMessage() . " in " . $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" . $e->getTraceAsString());
|
||||
|
||||
// Global Exception Handler (Never expose stack traces in production)
|
||||
Response::json([
|
||||
'success' => false,
|
||||
'message' => 'Unexpected system error'
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
app/Core/Exceptions/HttpException.php
Normal file
30
app/Core/Exceptions/HttpException.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Core\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class HttpException extends Exception
|
||||
{
|
||||
private string $errorCode;
|
||||
private array $data;
|
||||
|
||||
public function __construct(string $message, string $errorCode = 'ERROR', int $statusCode = 500, array $data = [])
|
||||
{
|
||||
parent::__construct($message, $statusCode);
|
||||
$this->errorCode = $errorCode;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function getErrorCode(): string
|
||||
{
|
||||
return $this->errorCode;
|
||||
}
|
||||
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user