Function combineErrors

  • Combines an array of errors into a single array.

    • If no errors are in the given array, a new Error with an empty message is returned.
    • If only one error is in the given array, it is directly returned without modification.

    Parameters

    • errors: readonly Error[]

    Returns Error

    A single error.

    import {combineErrors} from '@augment-vir/common';

    const result1 = combineErrors([new Error('message 1'), new Error('message 2')]); // result1 is a single error with the message 'message 1\nmessage 2'