1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-11 11:12:03 +02:00

All: Add more context to encryption errors

This commit is contained in:
Laurent Cozic 2020-03-04 16:53:45 +00:00
parent c617f43e42
commit 51ee872179
2 changed files with 13 additions and 5 deletions

View File

@ -341,7 +341,15 @@ class BaseItem extends BaseModel {
throw e;
}
const cipherText = await this.encryptionService().encryptString(serialized);
let cipherText = null;
try {
cipherText = await this.encryptionService().encryptString(serialized);
} catch (error) {
const msg = [`Could not encrypt item ${item.id}`];
if (error && error.message) msg.push(error.message);
throw new Error(msg.join(': '));
}
// List of keys that won't be encrypted - mostly foreign keys required to link items
// with each others and timestamp required for synchronisation.

View File

@ -295,7 +295,7 @@ class EncryptionService {
});
} catch (error) {
// SJCL returns a string as error which means stack trace is missing so convert to an error object here
throw new Error(error.message);
throw new Error(`SJCL error: ${error.message}`);
}
}
@ -313,7 +313,7 @@ class EncryptionService {
});
} catch (error) {
// SJCL returns a string as error which means stack trace is missing so convert to an error object here
throw new Error(error.message);
throw new Error(`SJCL error: ${error.message}`);
}
}
@ -331,7 +331,7 @@ class EncryptionService {
});
} catch (error) {
// SJCL returns a string as error which means stack trace is missing so convert to an error object here
throw new Error(error.message);
throw new Error(`SJCL error: ${error.message}`);
}
}
@ -348,7 +348,7 @@ class EncryptionService {
});
} catch (error) {
// SJCL returns a string as error which means stack trace is missing so convert to an error object here
throw new Error(error.message);
throw new Error(`SJCL error: ${error.message}`);
}
}