-
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.
Merge pull request #1245 from code-corps/fix-sync-dialyzer-errors
Fix GitHub sync dialyzer errors and add some specs to pagination errors
- Loading branch information
Showing
3 changed files
with
19 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
defmodule CodeCorps.GitHub.API.Errors.PaginationError do | ||
alias CodeCorps.GitHub.{HTTPClientError, APIError} | ||
alias CodeCorps.GitHub.{APIError, HTTPClientError} | ||
|
||
@type t :: %__MODULE__{ | ||
message: String.t, | ||
api_errors: list, | ||
client_errors: list, | ||
message: String.t, | ||
retrieved_pages: list | ||
} | ||
|
||
defstruct [ | ||
message: "One or more pages failed to retrieve during a GitHub API Pagination Request", | ||
retrieved_pages: [], | ||
api_errors: [], | ||
client_errors: [], | ||
api_errors: [] | ||
message: "One or more pages failed to retrieve when paginating GitHub API resources", | ||
retrieved_pages: [] | ||
] | ||
|
||
@spec new({list, list}) :: t | ||
def new({pages, errors}) do | ||
%__MODULE__{ | ||
retrieved_pages: pages, | ||
api_errors: errors |> Enum.filter(&api_error?/1), | ||
client_errors: errors |> Enum.filter(&client_error?/1), | ||
api_errors: errors |> Enum.filter(&api_error?/1) | ||
retrieved_pages: pages | ||
} | ||
end | ||
|
||
defp client_error?(%HTTPClientError{}), do: true | ||
defp client_error?(_), do: false | ||
@spec api_error?(APIError.t | any) :: boolean | ||
defp api_error?(%APIError{}), do: true | ||
defp api_error?(_), do: false | ||
|
||
@spec client_error?(HTTPClientError.t | any) :: boolean | ||
defp client_error?(%HTTPClientError{}), do: true | ||
defp client_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