[angular/angular] feat(core): introduce `@boundary` control flow and programmatic error handling (PR #70463)
DRANK
Introduces a declarative way to catch rendering errors in templates using the new `@boundary` block, preventing local failures from crashing the entire application hierarchy. ```angular-html @boundary { <complex-chart [data]="data" /> } @error (let err = $error; let r = $retry) { <p>Failed to load chart: {{err.message}}</p> <button (click)="r()">Retry</button> } ``` Additionally, this adds programmatic error handling for dynamically created views by introducing an `onError` option to `ViewContainerRef.createComponent`,`createEmbeddedView` and the standalone alone `createComponent` function: ```typescript viewContainerRef.createComponent(DynamicComponent, { onError: (err: Error, details: ErrorDetails) => { console.error('Component rendering failed:', err); // Render an alternative UI or log metrics } }); ``` Additional changes: - `ErrorHandler` can now implement `onViewError(err, details)` to receive rich metadata about caught boundary errors. Note: most of design & implementation was done by @alxhub.
🔖 "feat(core): introduce
@boundarycontrol flow and programmatic error handling by JeanMeche · Pull Request #70463 · angular/angular" github.com/angular/angula… #laco_feed