<script setup lang="ts">
import { fr } from "@nuxt/ui/locale";
import type { NuxtError } from "#app";

const props = defineProps<{ error: NuxtError }>();
const formattedError = computed(() => {
  const error = {
    statusCode: props.error.statusCode,
    statusMessage: props.error.statusMessage,
    message: props.error.message,
  };
  switch (error.statusCode) {
    case 404:
      error.statusMessage = "Page non trouvée";
      break;
    case 500:
      error.message = "Erreur interne du serveur.";
      break;
  }
  return error;
});
</script>

<template>
  <UApp :locale="fr">
    <UError :error="formattedError" />
  </UApp>
</template>
