func TestAggregateVtGateErrors(t *testing.T) { var testcases = []struct { input []error expected error }{ { input: nil, expected: nil, }, { input: []error{ errFromCode(vtrpc.ErrorCode_SUCCESS), errFromCode(vtrpc.ErrorCode_TRANSIENT_ERROR), errFromCode(vtrpc.ErrorCode_BAD_INPUT), }, expected: vterrors.FromError( vtrpc.ErrorCode_BAD_INPUT, vterrors.ConcatenateErrors([]error{errGeneric, errGeneric, errGeneric}), ), }, } for _, tc := range testcases { out := aggregateVtGateErrors(tc.input) if !reflect.DeepEqual(out, tc.expected) { t.Errorf("aggregateVtGateErrors(%+v) = %+v \nwant: %+v", tc.input, out, tc.expected) } } }
func aggregateVtGateErrors(errors []error) error { if len(errors) == 0 { return nil } return vterrors.FromError( aggregateVtGateErrorCodes(errors), vterrors.ConcatenateErrors(errors), ) }
func (e *ScatterConnError) Error() string { return fmt.Sprintf("%v", vterrors.ConcatenateErrors(e.Errs)) }