Wikipedia error handling
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
let isPointModalOpen: boolean = false;
|
let isPointModalOpen: boolean = false;
|
||||||
let isImageFetcherOpen: boolean = false;
|
let isImageFetcherOpen: boolean = false;
|
||||||
|
let wikiError: string = '';
|
||||||
|
|
||||||
let fileInput: HTMLInputElement;
|
let fileInput: HTMLInputElement;
|
||||||
let image: File;
|
let image: File;
|
||||||
@@ -55,8 +56,14 @@
|
|||||||
async function generateDesc() {
|
async function generateDesc() {
|
||||||
let res = await fetch(`/api/generate/desc/?name=${adventureToEdit.name}`);
|
let res = await fetch(`/api/generate/desc/?name=${adventureToEdit.name}`);
|
||||||
let data = await res.json();
|
let data = await res.json();
|
||||||
|
if (!res.ok) {
|
||||||
|
wikiError = 'No article found';
|
||||||
|
}
|
||||||
if (data.extract) {
|
if (data.extract) {
|
||||||
|
wikiError = '';
|
||||||
adventureToEdit.description = data.extract;
|
adventureToEdit.description = data.extract;
|
||||||
|
} else {
|
||||||
|
wikiError = 'No description found';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +233,9 @@
|
|||||||
><Wikipedia class="inline-block -mt-1 mb-1 w-6 h-6" />Generate Description</button
|
><Wikipedia class="inline-block -mt-1 mb-1 w-6 h-6" />Generate Description</button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
{#if wikiError}
|
||||||
|
<p class="text-red-500">{wikiError}</p>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if adventureToEdit.type == 'visited' || adventureToEdit.type == 'planned'}
|
{#if adventureToEdit.type == 'visited' || adventureToEdit.type == 'planned'}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
export let startDate: string | null = null;
|
export let startDate: string | null = null;
|
||||||
export let endDate: string | null = null;
|
export let endDate: string | null = null;
|
||||||
|
|
||||||
|
let wikiError: string = '';
|
||||||
|
|
||||||
let newAdventure: Adventure = {
|
let newAdventure: Adventure = {
|
||||||
id: '',
|
id: '',
|
||||||
type: type,
|
type: type,
|
||||||
@@ -105,8 +107,14 @@
|
|||||||
async function generateDesc() {
|
async function generateDesc() {
|
||||||
let res = await fetch(`/api/generate/desc/?name=${newAdventure.name}`);
|
let res = await fetch(`/api/generate/desc/?name=${newAdventure.name}`);
|
||||||
let data = await res.json();
|
let data = await res.json();
|
||||||
|
if (!res.ok) {
|
||||||
|
wikiError = 'No article found';
|
||||||
|
}
|
||||||
if (data.extract) {
|
if (data.extract) {
|
||||||
|
wikiError = '';
|
||||||
newAdventure.description = data.extract;
|
newAdventure.description = data.extract;
|
||||||
|
} else {
|
||||||
|
wikiError = 'No description found';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +315,9 @@
|
|||||||
><Wikipedia class="inline-block -mt-1 mb-1 w-6 h-6" />Generate Description</button
|
><Wikipedia class="inline-block -mt-1 mb-1 w-6 h-6" />Generate Description</button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
{#if wikiError}
|
||||||
|
<p class="text-red-500">{wikiError}</p>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if newAdventure.type == 'visited' || newAdventure.type == 'planned'}
|
{#if newAdventure.type == 'visited' || newAdventure.type == 'planned'}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user