CryptoPill icon indicating copy to clipboard operation
CryptoPill copied to clipboard

Include an NSError out on SecretBox methods for better error handling

Open gabriel opened this issue 11 years ago • 0 comments

When there is a problem encrypting or decrypting SecretBox returns nil. This is fine but it would be good to include an NSError out which lists why.

For example, instead of:

+ (NSData *)secretBoxDataOpen:(NSData *)encryptedData key:(SecureData *)key {
+ (NSData *)secretBoxDataOpen:(NSData *)encryptedData key:(SecureData *)key error:(NSError **)error {

and then in the method before returning nil in an error case:

if (error) *error = [NSError errorWithDomain.... ];

which gives the reason for the error.

gabriel avatar Jan 15 '14 23:01 gabriel