Partitions a slice into groups determined by a key computed from each element using an iteratee that can return an error. Stops iteration immediately when an error is encountered. Preserves original order.
// Error case - stops on first errorresult,err:=lo.PartitionByErr([]int{-2,-1,0,1,2,3},func(xint)(string,error){ifx==0{return"",fmt.Errorf("zero is not allowed")}ifx<0{return"negative",nil}elseifx%2==0{return"even",nil}return"odd",nil})// [][]int(nil), error("zero is not allowed")