Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Implement a unified type assertion errors handler #25

Open
amanenk opened this issue May 14, 2021 · 1 comment
Open

Implement a unified type assertion errors handler #25

amanenk opened this issue May 14, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@amanenk
Copy link
Contributor

amanenk commented May 14, 2021

There are a lot of type assertions that require checks and every time developer needs to build an error by hand.
An integrated solution would ease the process of development.
First construction that comes to mind:

r, ok := resource.Item.(types.Type)
if !ok {
return fmt.Errorf("wrong type assertion: got %s instead of %s", 
  reflect.TypeOf(r).Name(),
  reflect.TypeOf(types.Type{}).Name())
}
@amanenk amanenk added the enhancement New feature or request label May 14, 2021
@amanenk
Copy link
Contributor Author

amanenk commented Dec 23, 2021

Since we tell which type of object we use when generating a code we can try to implement it in cq-gen to automatically generate such a check in fetchers and resolvers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant