Improved error handling on identity creation

canary
WolverinDEV 2019-02-15 22:01:22 +01:00
parent 31aafa4e87
commit 0b203451d7
1 changed files with 7 additions and 1 deletions

View File

@ -396,7 +396,13 @@ namespace profiles.identities {
export class TeaSpeakIdentity implements Identity {
static async generate_new() : Promise<TeaSpeakIdentity> {
const key = await crypto.subtle.generateKey({name:'ECDH', namedCurve: 'P-256'}, true, ["deriveKey"]);
let key: CryptoKeyPair;
try {
key = await crypto.subtle.generateKey({name:'ECDH', namedCurve: 'P-256'}, true, ["deriveKey"]);
} catch(e) {
console.error(tr("Could not generate a new key: %o"), e);
throw "Failed to generate keypair";
}
const private_key = await CryptoHelper.export_ecc_key(key.privateKey, false);
const identity = new TeaSpeakIdentity(private_key, "0", undefined, false);