🥅 Catching error if quiz not found in practice-mode
This commit is contained in:
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
const get_quiz = async () => {
|
const get_quiz = async () => {
|
||||||
const res = await fetch(`/api/v1/quiz/get/public/${$page.url.searchParams.get('quiz_id')}`);
|
const res = await fetch(`/api/v1/quiz/get/public/${$page.url.searchParams.get('quiz_id')}`);
|
||||||
|
if (!res.ok) {
|
||||||
|
throw res.status;
|
||||||
|
}
|
||||||
quiz = await res.json();
|
quiz = await res.json();
|
||||||
return quiz;
|
return quiz;
|
||||||
};
|
};
|
||||||
@@ -85,4 +88,10 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{:catch e}
|
||||||
|
{#if e === 404 || e === 400}
|
||||||
|
<h1 class="text-center text-5xl">Quiz not found!</h1>
|
||||||
|
{:else}
|
||||||
|
<h1 class="text-center text-5xl">unknown error!</h1>
|
||||||
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
|
|||||||
Reference in New Issue
Block a user