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

Add error as a Primitive Type #1188

Closed
wants to merge 1 commit into from

Conversation

Niennienzz
Copy link

@Niennienzz Niennienzz commented Apr 27, 2022

Describe the PR

  • When the handler is returning a custom error struct type, and it contains the built-in error interface like below, the error :cannot find type definition: error would occur.
type ErrorResponse struct {
	Message string `json:"message"`
	Cause   error  `json:"cause"`
}
  • I am thinking, since the error interface is also a built-in type, and when it marshals to JSON using the interface (instead of any underneath implementation), it should be translated to a string.
  • Please let me know if/where I should add more tests!

Relation Issue

#1171

@Niennienzz Niennienzz marked this pull request as draft April 27, 2022 04:03
@ubogdan
Copy link
Contributor

ubogdan commented Apr 27, 2022

@Niennienzz Thanks for your contribution, but we won't make this kind of change because the error type is an interface and doesn't get marshaled by default.
We may add the feature to skip this field with a warning so "swag" will not end with an error, but this is entirely another story.

@ubogdan ubogdan closed this Apr 27, 2022
@ubogdan ubogdan reopened this Apr 27, 2022
@codecov
Copy link

codecov bot commented Apr 27, 2022

Codecov Report

Merging #1188 (370d098) into master (636f456) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1188   +/-   ##
=======================================
  Coverage   95.03%   95.03%           
=======================================
  Files          10       10           
  Lines        2557     2557           
=======================================
  Hits         2430     2430           
  Misses         69       69           
  Partials       58       58           
Impacted Files Coverage Δ
schema.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 636f456...370d098. Read the comment docs.

@ubogdan
Copy link
Contributor

ubogdan commented May 3, 2022

Please let me know if you are interested on making the change described by me or we can close this PR.

@Niennienzz
Copy link
Author

Please let me know if you are interested on making the change described by me or we can close this PR.

Please close for now. I would love to, but currently I am a bit busy with other projects...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants