refactor(crypto): minor refactor of decryptWithAttachments#65
refactor(crypto): minor refactor of decryptWithAttachments#65
Conversation
a8c6848 to
5350bae
Compare
| class AttachmentDecryptionError extends Error { | ||
| constructor(message = 'Attachment decryption with the given nonce failed.') { | ||
| super(message) | ||
| this.name = this.constructor.name |
There was a problem hiding this comment.
out of curiosity, why is this line necessary?
There was a problem hiding this comment.
it isn't! i actually left it in because i thought it was convention @__@ i'll remove it!
There was a problem hiding this comment.
i went to investigate more and it was q enlightening for me! the reason why this is done is because it's an error. when js (and by extension, ts) throws an error, the error printed to the output is done using error.name + ' ' + error.message - this means that when the error here is thrown, because it's missing the name property, it will default to Error (as it calls super(message)). While the argument might be that it's guaranteed to never be thrown, i think this is a relatively small change that helps in the future so i'd just leave it in!
Problem
Refactored
decryptWithAttachmentsfor additional clarityIssues faced
try/catchblock