Function Catch

  • Component prototype property decorator factory. Applying the Catch decorator to a property, while optionally supplying a trap will navigate to the Component containing the decorated property when an error, traped by this Catch decorator, occurs during navigation.

    Parameters

    • Optional trap: Catch

      The Catch callback deciding whether to trap an error.

    Returns ((prototype, propertyKey) => void)

    A Component prototype property decorator.

      • (prototype, propertyKey): void
      • Parameters

        Returns void

    Example

    Catch all URIErrors:

    import { Component, Catch } from '@sgrud/shell';

    declare global {
    interface HTMLElementTagNameMap {
    'example-component': ExampleComponent;
    }
    }

    ⁠@Component('example-component')
    export class ExampleComponent extends HTMLElement implements Component {

    ⁠@Catch((error) => error instanceof URIError)
    public readonly error?: URIError;

    public get template(): JSX.Element {
    return <span>Error message: {this.error?.message}</span>;
    }

    }

    See

    CatchQueue

Generated using TypeDoc