-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issues and inconsistencies with pagination api
- added API.Errors namespace, to move other errors into - added API.Errors.PaginationError - rewrote some specs that were breaking contracts - standardized get_all response to match request response - corrected several type definitions - added support for recovering from failed individual page requests during get_all - added support for recovering from failed initial head request during get_all - added support for marshalling a failed and succesful head response (body is "") - rewrote ResultAggregator docs and argument names so they reflect the fact that it can be used for aggregating any standard response list, not just db commit - wrote tests to cover new behaviors
- Loading branch information
Showing
15 changed files
with
226 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule CodeCorps.GitHub.API.Errors.PaginationError do | ||
alias CodeCorps.GitHub.{HTTPClientError, APIError} | ||
|
||
@type t :: %__MODULE__{ | ||
message: String.t, | ||
api_errors: list, | ||
client_errors: list, | ||
retrieved_pages: list | ||
} | ||
|
||
defstruct [ | ||
message: "One or more pages failed to retrieve during a GitHub API Pagination Request", | ||
retrieved_pages: [], | ||
client_errors: [], | ||
api_errors: [] | ||
] | ||
|
||
def new({pages, errors}) do | ||
%__MODULE__{ | ||
retrieved_pages: pages, | ||
client_errors: errors |> Enum.filter(&is_client_error?/1), | ||
api_errors: errors |> Enum.filter(&is_api_error?/1) | ||
} | ||
end | ||
|
||
defp is_client_error?(%HTTPClientError{}), do: true | ||
defp is_client_error?(_), do: false | ||
defp is_api_error?(%APIError{}), do: true | ||
defp is_api_error?(_), do: false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.