-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Http status mapping registrable #16
Conversation
types/errors/errors.go
Outdated
"reflect" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/rest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It causes cyclic import
types/errors/errors.go
Outdated
@@ -87,6 +89,10 @@ var ( | |||
ErrPanic = Register(UndefinedCodespace, 111222, "panic") | |||
) | |||
|
|||
func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needed to be moved to the rest package
types/errors/errors.go
Outdated
@@ -87,6 +89,10 @@ var ( | |||
ErrPanic = Register(UndefinedCodespace, 111222, "panic") | |||
) | |||
|
|||
func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use init
?
IMO, the table can be filled in static time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add init
for mapping error using RegisterHttpStatusMapping
then, is it ok to fill the table like
var (
table = HTTPStatusMappingTable{
errors.RootCodespace: {
errors.ErrUnknownAddress.ABCICode(): http.StatusNotFound,
},
}
)
this? (in rest package) (i think it can solve two problem above also)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make the commit for it so that let me see what you intended.
@kfangw thanks for your review. |
Fix the bug that should be used `operator` address when `to` address is nil on CreateFTClass
Next step of #14
Description
Two changes for mapping http status and error
1.Make a mapping http status and error registrable using error instance.
2.Remove hard-coded error code.