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

Report error message to user of SDK #17

Closed
jpcoenen opened this issue May 11, 2021 · 1 comment · Fixed by #24
Closed

Report error message to user of SDK #17

jpcoenen opened this issue May 11, 2021 · 1 comment · Fixed by #24
Assignees

Comments

@jpcoenen
Copy link
Member

Summary

Instead of only returning the status code to the user of the SDK, it would be helpful if the SDK also returned the error message returned by Connect, if available.

Use cases

This makes it way easier to debug problems, especially validations issues.

If you currently try to create a new Item, but it does not adhere to the required structure, you only get this response:

Unable to create item. Receieved "400 Bad Request" for "/v1/vaults/UUID/items "

Proposed solution

I propose two possible solutions:

  1. Append the error message to the current string-based error message. I.e. Unable to create item. Receieved "400 Bad Request" for "/v1/vaults/UUID/items": Validation: (validateVaultItem failed to Validate), Couldn't validate the item: "[ItemValidator] has found 1 errors, 0 warnings: \nErrors:{1. details.sections[0].fields[0] has unsupported field type}"
  2. Create a custom error type that exposes the status code and the message to the user of the SDK.

The second option is a little more involved, but I think it's the most flexible to work with and is my preferred option.

@thatguygriff
Copy link

I definitely prefer the custom error type

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 a pull request may close this issue.

4 participants