forked from trent_larson/crowd-funder-for-time-pwa
add more error handling and messaging when there are bad DB errors
This commit is contained in:
@@ -539,20 +539,23 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
|
||||
const identity = JSON.stringify(newId);
|
||||
|
||||
// one of the few times we use accountsDBPromise directly; try to avoid more usage
|
||||
const accountsDB = await accountsDBPromise;
|
||||
await accountsDB.accounts.add({
|
||||
dateCreated: new Date().toISOString(),
|
||||
derivationPath: derivationPath,
|
||||
did: newId.did,
|
||||
identity: identity,
|
||||
mnemonic: mnemonic,
|
||||
publicKeyHex: newId.keys[0].publicKeyHex,
|
||||
});
|
||||
|
||||
await updateDefaultSettings({ activeDid: newId.did });
|
||||
//console.log("Updated default settings in util");
|
||||
try {
|
||||
const accountsDB = await accountsDBPromise;
|
||||
await accountsDB.accounts.add({
|
||||
dateCreated: new Date().toISOString(),
|
||||
derivationPath: derivationPath,
|
||||
did: newId.did,
|
||||
identity: identity,
|
||||
mnemonic: mnemonic,
|
||||
publicKeyHex: newId.keys[0].publicKeyHex,
|
||||
});
|
||||
|
||||
await updateDefaultSettings({ activeDid: newId.did });
|
||||
} catch (error) {
|
||||
console.error("Failed to update default settings:", error);
|
||||
throw new Error("Failed to set default settings. Please try again or restart the app.");
|
||||
}
|
||||
await updateAccountSettings(newId.did, { isRegistered: false });
|
||||
|
||||
return newId.did;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user