Skip to content

Simplify the utilities #10

@Byloth

Description

@Byloth

Consider to simplify all the utilities to be better used in Promise and async situations.

e.g.

export function expect<T extends object, R = void>(type: Constructor<T>, handler: (error: T) => R): (error: unknown) => R | never
{
    return (error: unknown): R | never =>
    {
        if (error instanceof type) { return handler(error); }

        throw error;
    };
}

new Promise([...])
    .catch(expect(ValueError, (error: ValueError) => { ... });

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions