Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to catch IPX errors and show fallback with NuxtImg or NuxtPicture? #1259

Open
oemer-aran opened this issue Feb 23, 2024 · 0 comments
Open

Comments

@oemer-aran
Copy link

I tried to use @error on NuxtImg and <NuxtErrorBoundary> component, but nothing works:

<template>
 <nuxt-error-boundary @error="handleError">
  <nuxt-img
    @error="handleError"
    @load="handleLoad"
    :src="url"
  />
  <template #error="{ error }">
    <p>This is never displayed: {{ error }}</p>
  </template>
</nuxt-error-boundary>
</template>

<script lang="ts" setup>
  const handleError = (e) => {
    // never gets printed, even if no image is displayed and ipx had an error
    console.log("error", e)
  }
  
  const handleLoad = (e) => {
    // gets printed when image is loaded successfully
    console.log("load", e)
  }
</script>

Here is the full IPX error (also see screenshot):

{
  "error": {
    "message": "[400] [IPX_INVALID_IMAGE] Cannot parse image metadata: http://localhost:4566/<image-url>"
  }
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant