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

adding new error response object #240

Merged
merged 5 commits into from
Oct 25, 2022
Merged

adding new error response object #240

merged 5 commits into from
Oct 25, 2022

Conversation

nitro-neal
Copy link
Contributor

No description provided.

}

// GetErrorResponse will get the type of err, if the type is a ErrorResponse it will return that as an ErrorResponse, otherwise it will construct a new default ErrorResponse
func GetErrorResponse(err error) ErrorResponse {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not working for me:

var errorResponse ErrorResponse
errorBytes, e := json.Marshal(err)
if e != nil {
return ErrorResponse{Valid: false, Err: err, ErrorType: UnknownError}
}
if e = json.Unmarshal(errorBytes, &errorResponse); err != nil {
return ErrorResponse{Valid: false, Err: err, ErrorType: UnknownError}
}

@@ -98,7 +98,7 @@ func TestCredentialApplication(t *testing.T) {
func TestCredentialResponse(t *testing.T) {
// example here https://identity.foundation/credential-manifest/#credential-response

t.Run("Credential Response - Fulfillment Vector 1", func(tt *testing.T) {
t.Run("Credential ErrorResponse - Fulfillment Vector 1", func(tt *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

whoops


// GetErrorResponse will get the type of err, if the type is a ErrorResponse it will return that as an ErrorResponse, otherwise it will construct a new default ErrorResponse
func GetErrorResponse(err error) ErrorResponse {
errResponseTypeString := reflect.TypeOf(ErrorResponse{}).String()
Copy link
Member

Choose a reason for hiding this comment

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

ahh fun with reflection

@codecov-commenter
Copy link

Codecov Report

Merging #240 (92150b8) into main (196a321) will increase coverage by 0.21%.
The diff coverage is 67.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #240      +/-   ##
==========================================
+ Coverage   59.09%   59.31%   +0.21%     
==========================================
  Files          36       37       +1     
  Lines        4190     4234      +44     
==========================================
+ Hits         2476     2511      +35     
- Misses       1315     1324       +9     
  Partials      399      399              
Impacted Files Coverage Δ
credential/manifest/model.go 54.86% <38.89%> (-2.20%) ⬇️
error/response.go 100.00% <100.00%> (ø)

@decentralgabe decentralgabe merged commit 42ee002 into main Oct 25, 2022
@decentralgabe decentralgabe deleted the new-error-response branch October 25, 2022 01:57
decentralgabe added a commit that referenced this pull request Oct 26, 2022
* origin/main:
  fix bug (#242)
  adding new error response object (#240)

# Conflicts:
#	credential/manifest/model.go
#	credential/manifest/model_test.go
#	error/response.go
#	error/response_test.go
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.

None yet

3 participants