refactor(discovery): enhance exception handling and logging context in FileProcessor
- Add `DiscoveryErrorCode` and `FileSystemErrorCode` to improve error classification in `DiscoveryException`. - Integrate `LogContext` into `FileProcessor` warnings for enriched logging details. - Simplify `Environment` variable handling by removing redundant condition checks.
This commit is contained in:
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Discovery\Exceptions;
|
||||
|
||||
use App\Framework\Exception\Core\DiscoveryErrorCode;
|
||||
use App\Framework\Exception\Core\FileSystemErrorCode;
|
||||
use App\Framework\Exception\ErrorCode;
|
||||
use App\Framework\Exception\ExceptionContext;
|
||||
use App\Framework\Exception\FrameworkException;
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Framework\Filesystem\FileScanner;
|
||||
use App\Framework\Filesystem\FileSystemService;
|
||||
use App\Framework\Filesystem\ValueObjects\FilePattern;
|
||||
use App\Framework\Logging\Logger;
|
||||
use App\Framework\Logging\ValueObjects\LogContext;
|
||||
use App\Framework\Performance\MemoryMonitor;
|
||||
use Generator;
|
||||
use Throwable;
|
||||
@@ -129,7 +130,7 @@ final readonly class FileProcessor implements DiscoveryProcessor
|
||||
|
||||
} catch (Throwable $e) {
|
||||
$this->logger?->warning(
|
||||
"Failed to process file {$file->getPath()->toString()}: {$e->getMessage()}"
|
||||
"Failed to process file {$file->getPath()->toString()}: {$e->getMessage()}", LogContext::withException($e)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user