Browse Source

chore: explicitly share error message used for logic

pull/189/head
Trent Larson 3 days ago
parent
commit
fa8956fb38
  1. 4
      src/libs/util.ts
  2. 3
      src/views/ImportAccountView.vue

4
src/libs/util.ts

@ -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}`,
);
}

3
src/views/ImportAccountView.vue

@ -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,

Loading…
Cancel
Save