Class Settler<Input>

Error handler that collects all errors during the pipeline execution. Compiling the data will return the data along with the errors.

function* gen() {
yield 1;
throw new Error("test error");
yield 3;
}

const stream = new ArrayStream(gen, new Settler())
.map(x => {
if (x === 3) {
throw new Error("test error");
}
return x;
})
.collect();
// {
// data: [1],
// errors: [
// "Error occurred at item at index 1 in iterator: test error",
// "Error occurred while performing map on 3 at index 2 in iterator: test error"
// ]
// }

Type Parameters

  • Input

Implements

Constructors

Properties

errors: string[] = []

Methods

  • Collects an error and adds more context when an error occurs during an iteration, i.e.

    function* gen() {
    yield 1;
    throw new Error("test error");
    }

    const stream = new ArrayStream(gen, new Settler()).collect();
    // {
    // data: [1],
    // errors: [
    // "Error occurred at item at index 1 in iterator: test error",
    // ]
    // }

    Parameters

    • error: unknown
    • index: number

    Returns void

  • Collects an error and adds more context when an error occurs during an operation, i.e.

    const stream = new ArrayStream([1,2,3], new Settler())
    .map(x => {
    if (x === 3) {
    throw new Error("test error");
    }
    return x;
    })
    .collect();
    // {
    // data: [1,2],
    // errors: [
    // "Error occurred while performing map on 3 at index 2 in iterator: test error"
    // ]
    // }

    Parameters

    • error: unknown
    • index: number
    • item: Input
    • op: string

    Returns void