Files
XC_VM/docs/en/development/exception-hierarchy.md
T
Divarion-D 76844fef11 docs: restructure, fix PSR-4 drift, and unify en/ru
Overhaul the Docsify documentation (English + Russian) so it matches the current
codebase and follows one consistent pattern.

Content accuracy (post-migration):
- Rewrite development/autoloader.md to PSR-4 / Composer (the old XC_Autoloader
  scanner, igbinary tmp/cache/autoload_map and registerDirectories are gone).
- PascalCase every source path (src/core -> src/Core, domain/Stream, cli/Commands,
  public/Controllers, Infrastructure/Redis, ...) across all docs.
- Replace the removed autoload.php references with vendor/autoload.php
  (build_system, bootstrap-contexts, error-handling, modules).
- ssl-generation: note that the installer now auto-generates a unique self-signed
  certificate before Nginx starts.

Common pattern (Clean & uniform):
- Strip emoji from headings; remove the in-page Navigation blocks (the Docsify
  sidebar already provides navigation).
- One H1 + intro per doc; uniform "Related files" / "Связанные файлы" section,
  added to the code-centric docs that lacked it.

Structure:
- Remove the empty stray docs/api/; move updates_checklist.md into builds/;
  link the previously-orphaned ucs-integration.md.
- Regroup the sidebars (split the oversized guides group into Developer Guides /
  Security & Access / Integrations; fold builds into Build & Release).

Augment:
- dev-workflow: Local Setup (make dev-tools) + Quality Checks (phpstan, cs, gates).
- build_system: Composer Dependencies section (committed prod-only vendor,
  committed lock, dev tools via composer install, no build-time vendor step).

en/ru parity:
- Apply the same structure, fixes and pattern to docs/ru/ (translated), including
  a new Russian ucs-integration.md. The en and ru file sets are now identical.
2026-06-26 15:56:15 +03:00

111 lines
2.8 KiB
Markdown

# Exception Hierarchy
All XC_VM exceptions extend `XcVmException` so callers can catch the entire tree with
one `catch` block or target a specific subsystem.
---
## Tree
```
\Exception
└── XcVmException
├── Container
│ └── ContainerException (PSR-11 ContainerExceptionInterface)
│ ├── CircularDependencyException
│ ├── ServiceCreationException
│ └── NotFoundException (PSR-11 NotFoundExceptionInterface)
└── Module
└── ModuleException
├── ModuleNotFoundException
├── ModuleLoadException
├── ModuleManifestException
└── ModuleCycleException
```
---
## Container exceptions
| Class | When thrown |
| ----- | ----------- |
| `ContainerException` | Base for all container failures |
| `CircularDependencyException` | A service's factory graph contains a cycle |
| `ServiceCreationException` | Factory callable threw while creating a service |
| `NotFoundException` | `get($id)` called for an unregistered service |
`NotFoundException` implements both PSR-11 interfaces so the container is compliant:
```php
try {
$service = $container->get('unknown');
} catch (NotFoundException $e) {
// PSR-11 NotFoundExceptionInterface
}
```
---
## Module exceptions
| Class | When thrown |
| ----- | ----------- |
| `ModuleException` | Base for all module failures |
| `ModuleNotFoundException` | Required dependency module is missing |
| `ModuleLoadException` | Module file cannot be loaded or class not found |
| `ModuleManifestException` | `module.json` is missing, malformed, or fails validation |
| `ModuleCycleException` | Dependency graph has a cycle |
---
## Catching by subsystem
```php
// Catch any XC_VM exception
try {
$loader->loadAll();
} catch (XcVmException $e) {
logger()->error($e->getMessage());
}
// Catch only module-related failures
try {
$loader->loadAll();
} catch (ModuleException $e) {
// ModuleNotFoundException | ModuleLoadException | ...
}
// Catch container-specific failures
try {
$container->get('missing');
} catch (ContainerException $e) {
// CircularDependencyException | NotFoundException | ...
}
```
---
## Location
```
src/Core/Exception/
├── XcVmException.php
├── Container/
│ ├── ContainerException.php
│ ├── CircularDependencyException.php
│ ├── ServiceCreationException.php
│ └── NotFoundException.php
└── Module/
├── ModuleException.php
├── ModuleNotFoundException.php
├── ModuleLoadException.php
├── ModuleManifestException.php
└── ModuleCycleException.php
```
## Related files
| File | Role |
| --- | --- |
| `src/Core/Exception/` | Exception base classes and the project hierarchy |