You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for providing this package :) I'm using libsodium to verify a signature in my Android app and was really surprised just now when I realized that VerifyKey.verify() (more precisely: Util.isValid()) throws a RuntimeException. At least for me, this was really unexpected and I think it's also not the most elegant solution. Basically, if I want to handle this case gracefully (instead of crashing my app), I have to catch all RuntimeExceptions and compare the message with a constant string that could potentially change in future versions. A few ideas on alternative ways to handle this (in my personal order of preference):
Just let it return false when the signature isn't valid and let developers handle what should happen in that case. After all, it is a boolean method, so just by looking at the interface I would expect it to return true if the signature is valid and false otherwise. Imho, there's no need to throw an exception at all.
Don't use RuntimeException but create a new (checked!) exception class, so that at least I will be prompted to handle that case while writing the code.
At the very minimum, make it a new subclass of RuntimeException, so I don't need to catch all the RuntimeExceptions, but can easily catch "InvalidSignatureException" or similar.
Is there any chance you would be making one of these changes in a future version? Or is there a particular reason you went for the RuntimeException?
The text was updated successfully, but these errors were encountered:
I'm happy to provide a patch, I'm just not sure when I will get around to doing that. Also, this change might break existing code in a subtle way, i.e. if people are relying on the fact that an invalid signature will throw an exception and don't check the return value at all. Need to make sure to communicate that properly somehow...
First of all, thanks for providing this package :) I'm using libsodium to verify a signature in my Android app and was really surprised just now when I realized that VerifyKey.verify() (more precisely: Util.isValid()) throws a RuntimeException. At least for me, this was really unexpected and I think it's also not the most elegant solution. Basically, if I want to handle this case gracefully (instead of crashing my app), I have to catch all RuntimeExceptions and compare the message with a constant string that could potentially change in future versions. A few ideas on alternative ways to handle this (in my personal order of preference):
Is there any chance you would be making one of these changes in a future version? Or is there a particular reason you went for the RuntimeException?
The text was updated successfully, but these errors were encountered: