forked from trent_larson/crowd-funder-for-time-pwa
chore: explicitly share error message used for logic
This commit is contained in:
@@ -614,6 +614,8 @@ export const retrieveAllAccountsMetadata = async (): Promise<
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DUPLICATE_ACCOUNT_ERROR = "Cannot import duplicate account.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a new identity to both SQL and Dexie databases
|
* Saves a new identity to both SQL and Dexie databases
|
||||||
*/
|
*/
|
||||||
@@ -634,7 +636,7 @@ export async function saveNewIdentity(
|
|||||||
|
|
||||||
if (existingAccount?.values?.length) {
|
if (existingAccount?.values?.length) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Account with DID ${identity.did} already exists. Cannot import duplicate account.`,
|
`Account with DID ${identity.did} already exists. ${DUPLICATE_ACCOUNT_ERROR}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ import {
|
|||||||
retrieveAccountCount,
|
retrieveAccountCount,
|
||||||
importFromMnemonic,
|
importFromMnemonic,
|
||||||
checkForDuplicateAccount,
|
checkForDuplicateAccount,
|
||||||
|
DUPLICATE_ACCOUNT_ERROR,
|
||||||
} from "../libs/util";
|
} from "../libs/util";
|
||||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||||
@@ -245,7 +246,7 @@ export default class ImportAccountView extends Vue {
|
|||||||
// Check if this is a duplicate account error from saveNewIdentity
|
// Check if this is a duplicate account error from saveNewIdentity
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
error instanceof Error ? error.message : String(error);
|
error instanceof Error ? error.message : String(error);
|
||||||
if (errorMessage.includes("Cannot import duplicate account")) {
|
if (errorMessage.includes(DUPLICATE_ACCOUNT_ERROR)) {
|
||||||
this.notify.warning(
|
this.notify.warning(
|
||||||
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
||||||
TIMEOUTS.LONG,
|
TIMEOUTS.LONG,
|
||||||
|
|||||||
Reference in New Issue
Block a user