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 · 1 comment
Open
Labels
question Further information is requested

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

@Baroshem
Copy link
Collaborator

I think that this error is not releated to the image component but rather a build option.

I dont think that you can catch this kind of error this way. Maybe a better option would be to catch this error during build? I am not sure what you are trying to achieve here as well. Could you elaborate? :)

@Baroshem Baroshem added the question Further information is requested label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants