Skip to content
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

private/mode/api: Add codegen typed Errors for RESTJSON and JSONRPC APIs #3062

Merged
merged 10 commits into from
Jan 10, 2020

Conversation

jasdel
Copy link
Contributor

@jasdel jasdel commented Jan 4, 2020

Adds code generated error types for APIs using RESTJSON and JSONRPC protocol, and modeled errors. This adds generated error types that can be typed asserted to in order to read error values in addition to Code and Message.

TODO:

  • Update DDB transaction canceled example
  • Handling of error members with http binding
  • cleanup/testing
  • reduce duplication of protocol error unmarshalers

@jasdel jasdel added the pr/work-in-progress This PR is a draft and needs further work. label Jan 4, 2020
@jasdel jasdel self-assigned this Jan 4, 2020
@jasdel jasdel force-pushed the feat/GeneratedTypedErrors branch 2 times, most recently from b0f208a to d081b04 Compare January 6, 2020 23:50
@jasdel jasdel added needs-review This issue or pull request needs review from a core team member. and removed pr/work-in-progress This PR is a draft and needs further work. labels Jan 7, 2020
@jasdel jasdel force-pushed the feat/GeneratedTypedErrors branch 2 times, most recently from 5d59e7e to 8eb1550 Compare January 8, 2020 01:19
Comment on lines +24 to +28
func NewUnmarshalErrorHandler(unmarshaler ErrorUnmarshaler) *UnmarshalErrorHandler {
return &UnmarshalErrorHandler{
unmarshaler: unmarshaler,
}
}
Copy link
Contributor

@skotambkar skotambkar Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor not needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of these constructors is to reinforce the idea that the passed in parameters is a required parameter and the type must be created with its value. When doing struct initialization there is no clear signal what if anything is required members. This is the reason constructors may be preferred for initializing a type.

private/model/api/api.go Outdated Show resolved Hide resolved
Copy link
Contributor

@skotambkar skotambkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes suggested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review This issue or pull request needs review from a core team member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants