function createError()

in lib/errors.js [84:96]


function createError(messages, errCode, meta) {
    // The error value may be "undefined", so check if the argument was provided
    const hasValue = meta && 'value' in meta;
    // Throw a custom error type with the code attached
    const err = new Error(
        `${messages[errCode] || UNKNOWN_ERROR_MSG} (code: ${errCode}${
            hasValue ? `, value: ${meta.value}` : ''
        })`
    );
    // @ts-expect-error - TS doesn't like extending Error
    err.code = errCode;
    return err;
}