Skip to content

Commit

Permalink
better error handling and dialyzer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiercy827 committed Oct 8, 2018
1 parent 0fa5ad1 commit 0c6144f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/lob/resource_base.ex
Expand Up @@ -23,7 +23,7 @@ defmodule Lob.ResourceBase do
def list!(params \\ %{}, headers \\ %{}) do
case list(params, headers) do
{:ok, body, headers} -> {body, headers}
error -> raise to_string(error)
{:error, error} -> raise to_string(error)
end
end
end
Expand All @@ -38,7 +38,7 @@ defmodule Lob.ResourceBase do
def retrieve!(id, headers \\ %{}) do
case retrieve(id, headers) do
{:ok, body, headers} -> {body, headers}
error -> raise to_string(error)
{:error, error} -> raise to_string(error)
end
end
end
Expand All @@ -49,11 +49,11 @@ defmodule Lob.ResourceBase do
Client.post_request(base_url(), Util.build_body(data), Util.build_headers(headers))
end

@spec create!(String.t, map) :: {map, list}
@spec create!(map, map) :: {map, list}
def create!(data, headers \\ %{}) do
case create(data, headers) do
{:ok, body, headers} -> {body, headers}
error -> raise to_string(error)
{:error, error} -> raise to_string(error)
end
end
end
Expand All @@ -68,7 +68,7 @@ defmodule Lob.ResourceBase do
def delete!(id, headers \\ %{}) do
case delete(id, headers) do
{:ok, body, headers} -> {body, headers}
error -> raise to_string(error)
{:error, error} -> raise to_string(error)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lob/util.ex
Expand Up @@ -38,7 +38,7 @@ defmodule Lob.Util do
iex> Lob.Util.build_headers(%{"Idempotency-Key" => "abc123", "Lob-Version" => "2017-11-08"})
[{"Idempotency-Key", "abc123"}, {"Lob-Version", "2017-11-08"}]
"""
@spec build_headers(list({any, any})) :: HTTPoison.Base.headers
@spec build_headers(map) :: HTTPoison.Base.headers
def build_headers(headers) do
headers
|> Enum.to_list
Expand Down

0 comments on commit 0c6144f

Please sign in to comment.