Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit f0d2555

Browse files
committed
refactor(renaming): error: error -> error: reason
1 parent 85b0986 commit f0d2555

File tree

8 files changed

+19
-21
lines changed

8 files changed

+19
-21
lines changed

lib/groupher_server/accounts/delegates/fans.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ defmodule GroupherServer.Accounts.Delegate.Fans do
4040
false ->
4141
{:error, [message: "can't follow yourself", code: ecode(:self_conflict)]}
4242

43-
{:error, error} ->
44-
{:error, [message: error, code: ecode(:not_exsit)]}
43+
{:error, reason} ->
44+
{:error, [message: reason, code: ecode(:not_exsit)]}
4545
end
4646
end
4747

@@ -89,8 +89,8 @@ defmodule GroupherServer.Accounts.Delegate.Fans do
8989
false ->
9090
{:error, [message: "can't undo follow yourself", code: ecode(:self_conflict)]}
9191

92-
{:error, error} ->
93-
{:error, [message: error, code: ecode(:not_exsit)]}
92+
{:error, reason} ->
93+
{:error, [message: reason, code: ecode(:not_exsit)]}
9494
end
9595
end
9696

lib/groupher_server/accounts/delegates/favorite_category.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ defmodule GroupherServer.Accounts.Delegate.FavoriteCategory do
149149
{:error, _} ->
150150
case CMS.reaction(thread, :favorite, content_id, user) do
151151
{:ok, _} -> find_content_favorite(thread, content_id, user.id)
152-
{:error, error} -> {:error, error}
152+
{:error, reason} -> {:error, reason}
153153
end
154154
end
155155
end)
@@ -160,7 +160,7 @@ defmodule GroupherServer.Accounts.Delegate.FavoriteCategory do
160160
|> ORM.update(%{total_count: max(old_category.total_count - 1, 0)})
161161
else
162162
true -> {:ok, ""}
163-
error -> {:error, error}
163+
reason -> {:error, reason}
164164
end
165165
end)
166166
|> Multi.run(:update_content_category_id, fn _, %{favorite_content: content_favorite} ->

lib/groupher_server/cms/delegates/community_curd.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do
174174
{:ok, ret} ->
175175
{:ok, ret}
176176

177-
{:error, error} ->
178-
{:error, error}
177+
{:error, reason} ->
178+
{:error, reason}
179179
end
180180
end
181181

lib/helper/utils.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ defmodule Helper.Utils do
3535
def done(_, :boolean), do: {:ok, true}
3636
def done(nil, err_msg), do: {:error, err_msg}
3737
def done({:ok, _}, with: result), do: {:ok, result}
38-
def done({:error, error}, with: _result), do: {:error, error}
38+
def done({:error, reason}, with: _result), do: {:error, reason}
3939

4040
def done({:ok, %{id: id}}, :status), do: {:ok, %{done: true, id: id}}
4141
def done({:error, _}, :status), do: {:ok, %{done: false}}
@@ -48,8 +48,6 @@ defmodule Helper.Utils do
4848
# for delete_all, update_all
4949
# see: https://groups.google.com/forum/#!topic/elixir-ecto/1g5Pp6ceqFE
5050
def done({n, nil}) when is_integer(n), do: {:ok, %{done: true}}
51-
52-
# def done({:error, error}), do: {:error, error}
5351
def done(result), do: {:ok, result}
5452

5553
def done_and_cache(result, scope, expire: expire_time) do

test/groupher_server/accounts/favorite_category_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ defmodule GroupherServer.Test.Accounts.FavoriteCategory do
2828

2929
test "user create dup favorite category fails", ~m(user)a do
3030
{:ok, _category} = Accounts.create_favorite_category(user, %{title: "test category"})
31-
{:error, error} = Accounts.create_favorite_category(user, %{title: "test category"})
31+
{:error, reason} = Accounts.create_favorite_category(user, %{title: "test category"})
3232

33-
assert error |> Keyword.get(:code) == ecode(:already_exsit)
33+
assert reason |> Keyword.get(:code) == ecode(:already_exsit)
3434
end
3535

3636
test "user can get public categories list", ~m(user)a do
@@ -120,8 +120,8 @@ defmodule GroupherServer.Test.Accounts.FavoriteCategory do
120120
{:ok, category} = Accounts.create_favorite_category(user, %{title: test_category})
121121
{:ok, _} = Accounts.set_favorites(user, :post, post.id, category.id)
122122

123-
{:error, error} = Accounts.set_favorites(user, :post, post.id, category.id)
124-
assert error |> Keyword.get(:code) == ecode(:already_did)
123+
{:error, reason} = Accounts.set_favorites(user, :post, post.id, category.id)
124+
assert reason |> Keyword.get(:code) == ecode(:already_did)
125125
end
126126

127127
test "user can unset category to a favorited post", ~m(user post)a do

test/groupher_server/billing/billing_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ defmodule GroupherServer.Test.Billing do
3636

3737
test "create bill record with previous record unhandled fails", ~m(user valid_attrs)a do
3838
{:ok, _record} = Billing.create_record(user, valid_attrs)
39-
{:error, error} = Billing.create_record(user, valid_attrs)
40-
assert error |> Keyword.get(:code) == ecode(:exsit_pending_bill)
39+
{:error, reason} = Billing.create_record(user, valid_attrs)
40+
assert reason |> Keyword.get(:code) == ecode(:exsit_pending_bill)
4141
end
4242

4343
test "record state can be update", ~m(user valid_attrs)a do

test/groupher_server/cms/cheatsheet_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ defmodule GroupherServer.Test.CMS.Cheatsheet do
5858
assert length(update_contributors) == 1 + length(cur_contributors)
5959

6060
# add some again
61-
{:error, error} = CMS.add_contributor(cheatsheet, contributor_attrs)
62-
assert error |> Keyword.get(:code) == ecode(:already_exsit)
61+
{:error, reason} = CMS.add_contributor(cheatsheet, contributor_attrs)
62+
assert reason |> Keyword.get(:code) == ecode(:already_exsit)
6363
end
6464
end
6565
end

test/groupher_server/cms/wiki_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ defmodule GroupherServer.Test.Wiki do
5656
assert length(update_contributors) == 1 + length(cur_contributors)
5757

5858
# add some again
59-
{:error, error} = CMS.add_contributor(wiki, contributor_attrs)
60-
assert error |> Keyword.get(:code) == ecode(:already_exsit)
59+
{:error, reason} = CMS.add_contributor(wiki, contributor_attrs)
60+
assert reason |> Keyword.get(:code) == ecode(:already_exsit)
6161
end
6262
end
6363
end

0 commit comments

Comments
 (0)