code_corps v0.0.1 CodeCorps.GitHub.Utils.ResultAggregator View Source

Used for aggregating a list of results.

Link to this section Summary

Functions

Aggregates a list of result tuples into a single result tuple

Link to this section Functions

Link to this function aggregate(results) View Source
aggregate(list()) :: {:ok, list()} | {:error, {list(), list()}}

Aggregates a list of result tuples into a single result tuple.

A result tuple is a two-element tuple where the first element is :ok, or :error, while the second element is the resulting data.

This function goes through a list of such tuples and aggregates the list into a single tuple where

  • if all tuples in the list are :ok tuples, returns {:ok, results}

  • if any tuple is an :error tuple, returns {:error, {results, errors}}

  • results and errors are lists of second tuple elements in their respective tuples