mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-07-22 11:41:48 +00:00
Translated error messages
This commit is contained in:
@@ -2,6 +2,7 @@ import {analyticsEvent} from '../util/analytics';
|
||||
import {convertGedcom, getSoftware, TopolaData} from '../util/gedcom_util';
|
||||
import {DataSource, DataSourceEnum, SourceSelection} from './data_source';
|
||||
import {IndiInfo, JsonGedcomData} from 'topola';
|
||||
import {TopolaError} from '../util/error';
|
||||
|
||||
/**
|
||||
* Returns a valid IndiInfo object, either with the given indi and generation
|
||||
@@ -89,7 +90,10 @@ export async function loadGedcom(
|
||||
console.warn('Failed to load data from session storage: ' + e);
|
||||
}
|
||||
if (!gedcom) {
|
||||
throw new Error('Error loading data. Please upload your file again.');
|
||||
throw new TopolaError(
|
||||
'ERROR_LOADING_UPLOADED_FILE',
|
||||
'Error loading data. Please upload your file again.',
|
||||
);
|
||||
}
|
||||
return prepareData(gedcom, hash, images);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {Date, DateOrRange, JsonFam, JsonIndi} from 'topola';
|
||||
import {GedcomData, normalizeGedcom, TopolaData} from '../util/gedcom_util';
|
||||
import {GedcomEntry} from 'parse-gedcom';
|
||||
import {InjectedIntl} from 'react-intl';
|
||||
import {TopolaError} from '../util/error';
|
||||
|
||||
/** Prefix for IDs of private individuals. */
|
||||
export const PRIVATE_ID_PREFIX = '~Private';
|
||||
@@ -172,7 +173,12 @@ async function getRelatives(
|
||||
handleCors,
|
||||
);
|
||||
if (response[0].items === null) {
|
||||
throw new Error(`WikiTree profile ${keysToFetch[0]} not found.`);
|
||||
const id = keysToFetch[0];
|
||||
throw new TopolaError(
|
||||
'WIKITREE_PROFILE_NOT_FOUND',
|
||||
`WikiTree profile ${id} not found`,
|
||||
{id},
|
||||
);
|
||||
}
|
||||
const fetchedResults = response[0].items.map(
|
||||
(x: {person: Person}) => x.person,
|
||||
@@ -236,8 +242,11 @@ export async function loadWikiTree(
|
||||
// Fetch the ancestors of the input person and ancestors of his/her spouses.
|
||||
const firstPerson = await getRelatives([key], handleCors);
|
||||
if (!firstPerson[0].Name) {
|
||||
throw new Error(
|
||||
`WikiTree profile ${key} is not accessible. Try logging in.`,
|
||||
const id = key;
|
||||
throw new TopolaError(
|
||||
'WIKITREE_PROFILE_NOT_ACCESSIBLE',
|
||||
`WikiTree profile ${id} is not accessible. Try logging in.`,
|
||||
{id},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -597,7 +606,10 @@ export class WikiTreeDataSource implements DataSource<WikiTreeSourceSpec> {
|
||||
source: SourceSelection<WikiTreeSourceSpec>,
|
||||
): Promise<TopolaData> {
|
||||
if (!source.selection) {
|
||||
throw new Error('WikiTree id needs to be provided');
|
||||
throw new TopolaError(
|
||||
'WIKITREE_ID_NOT_PROVIDED',
|
||||
'WikiTree id needs to be provided',
|
||||
);
|
||||
}
|
||||
try {
|
||||
const data = await loadWikiTree(
|
||||
|
||||
Reference in New Issue
Block a user