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

Raise exception on errors #5

Open
rwdaigle opened this issue Dec 3, 2015 · 4 comments
Open

Raise exception on errors #5

rwdaigle opened this issue Dec 3, 2015 · 4 comments

Comments

@rwdaigle
Copy link
Contributor

rwdaigle commented Dec 3, 2015

Like we do in Gala, we should raise an error when known error states are encountered. Looking at the lib it looks like one such state is when the mac verification fails.

Perhaps DigestVerificationError?

@mrezentes
Copy link
Contributor

@rwdaigle ruby code nitpicking requested for those errors.

@rwdaigle
Copy link
Contributor Author

rwdaigle commented Dec 4, 2015

Great! Couple design points:

This library should have one job - to decrypt the payment token. So, we should do as little else as possible, including modifying the decrypted keys. Whatever the keys/values are in the token, we should just return it and not make any assumptions about key naming.

If we remove the key renaming, I believe we will also be able to remove the need to do any JSON.parse or JSON.generate. Just return whatever is decrypted and let the caller decide how to parse. This is especially important because, in Ruby, there are many JSON parsing libraries offering various pros/cons, so keeping this concern outside the scope of the library gives the caller more flexibility.

Also, looking at DecryptionError, I think we should let whatever the underlying exception is just bubble up. Catching an exception and re-typing it like that only serves to obscure the original error context (message, line number, stack trace, etc...).

If we do the above, I think we remove the need for DecryptedMessageUnparseableError and DecryptionError.

@mrezentes
Copy link
Contributor

Exactly the type of feedback I was looking for. Thanks.

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

No branches or pull requests

2 participants