Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit4eac5ff

Browse files
committed
refactor(article-comments): helper for raise custom error
1 parentfee3ed7 commit4eac5ff

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

‎lib/groupher_server/cms/delegates/article_comment.ex‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
44
"""
55
importEcto.Query,warn:false
66
importHelper.Utils,only:[done:1]
7+
importHelper.ErrorCode
78

89
importGroupherServer.CMS.Utils.Matcher2
910
importShortMaps
@@ -682,8 +683,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
682683
defpupsert_comment_result({:ok,%{update_comment_flag:result}}),do:{:ok,result}
683684
defpupsert_comment_result({:ok,%{delete_article_comment:result}}),do:{:ok,result}
684685

685-
defpupsert_comment_result({:error,:create_comment,result,_steps})do
686-
{:error,result}
686+
defpupsert_comment_result({:error,:create_article_comment,result,_steps})do
687+
raise_error(:create_comment,result)
687688
end
688689

689690
defpupsert_comment_result({:error,:add_participator,result,_steps})do

‎lib/helper/error_code.ex‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ defmodule Helper.ErrorCode do
66
@changeset_base4100
77
@throttle_base4200
88
@account_base4300
9+
@comment_base4400
10+
11+
@specraise_error(Atom.t(),String.t())::{:error,[message:String.t(),code:Integer.t()]}
12+
defraise_error(code_atom,msg)do
13+
{:error,[message:msg,code:ecode(code_atom)]}
14+
end
915

1016
# account error code
1117
defecode(:account_login),do:@account_base+1
@@ -32,6 +38,9 @@ defmodule Helper.ErrorCode do
3238
defecode(:throttle_inverval),do:@throttle_base+1
3339
defecode(:throttle_hour),do:@throttle_base+2
3440
defecode(:throttle_day),do:@throttle_base+3
41+
#
42+
defecode(:create_comment),do:@comment_base+1
43+
3544
defecode,do:@default_base
3645
# def ecode(_), do: @default_base
3746
end

‎test/groupher_server/cms/article_comment_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ defmodule GroupherServer.Test.CMS.ArticleComment do
318318
end
319319

320320
describe"paged article comments"do
321-
@tag:wip2
321+
@tag:wip
322322
test"can load paged comments participators of a article",~m(user post)ado
323323
total_count=30
324324
page_number=1

‎test/groupher_server_web/query/cms/article_comment_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ defmodule GroupherServer.Test.Query.ArticleComment do
509509
}
510510
}
511511
"""
512-
@tag:wip2
512+
@tag:wip
513513
test"guest user can get paged participators",~m(guest_conn post user)ado
514514
total_count=30
515515
page_size=10

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp