forked from jsnbuchanan/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;
|
||||
};
|
||||
|
||||
export const DUPLICATE_ACCOUNT_ERROR = "Cannot import duplicate account.";
|
||||
|
||||
/**
|
||||
* Saves a new identity to both SQL and Dexie databases
|
||||
*/
|
||||
@@ -634,7 +636,7 @@ export async function saveNewIdentity(
|
||||
|
||||
if (existingAccount?.values?.length) {
|
||||
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,
|
||||
importFromMnemonic,
|
||||
checkForDuplicateAccount,
|
||||
DUPLICATE_ACCOUNT_ERROR,
|
||||
} from "../libs/util";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
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
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
if (errorMessage.includes("Cannot import duplicate account")) {
|
||||
if (errorMessage.includes(DUPLICATE_ACCOUNT_ERROR)) {
|
||||
this.notify.warning(
|
||||
NOTIFY_DUPLICATE_ACCOUNT_IMPORT.message,
|
||||
TIMEOUTS.LONG,
|
||||
|
||||
Reference in New Issue
Block a user