Giter Club home page Giter Club logo

Comments (4)

LinusBorg avatar LinusBorg commented on June 27, 2024 3

I don't see why you wouldn't want to pass in the code as it's described

Providing not just the code, but an URL to a description of the code is better DX as developers who might have been unaware of that page in the docs which is providing these explanations of error codes can directly jump there instead of wondering what 0 is supposed to mean and where to find out about its meaning.

You could do

- if (info === '0' info === 'setup function')
+ if (info.split('#')[1] === 'runtime-0' info === 'setup function')

...and we could adjust the docs accordingly. Alternatively, we could consider ... adding another argument, providing the plain error code - in dev and prod alike?

onErrorCaptured((error, instance, info, errorCode) => {
  console.log(info) // logs 'setup function' in dev, and the URL in prod
  console.log(errorCode) // logs '0' in both modes.
})

This would be an improvement without needing to revert the current behaviour, which would inadvertently break someone else's code.

from core.

edison1105 avatar edison1105 commented on June 27, 2024

Is your codebase dependent on error codes? I think this way, users can quickly navigate to the error code page.

Perhaps the documentation needs to be updated to avoid causing confusion for users.

from core.

roberthand9 avatar roberthand9 commented on June 27, 2024

I'm using suspense and allow errors in async child components to bubble to the parent component where they're handled by an onErrorCaptured hook. There's a check to see if the source of the error is a setup function as that's where I would expect any 'expected' errors to be thrown e.g. api request failed - I can then render an error screen based on this and stop the error going any further

Any errors that are not from a setup function are ignored in the hook and left to the default behaviour

In dev this works fine as I can compare the info parameter to 'setup function' but in prod it's the URL described above. I would expect the URL in dev mode in some way but it seems strange to have it in prod

I'm aware suspense is not stable and perhaps I am stretching the use of the onErrorCaptured hook - but it is currently the suggested method https://vuejs.org/guide/built-ins/suspense#error-handling

In any case the docs are incorrect as they are and I don't see why you wouldn't want to pass in the code as it's described

from core.

roberthand9 avatar roberthand9 commented on June 27, 2024

The documentation surrounding the onErrorCaptured hook is transparent that the argument is swapped in prod vs dev - but I can appreciate what you're saying

I did consider slicing the URL but it felt like relying on an unstable detail (please ignore my use of suspense for this argument...)

As you've suggested I think adding a further argument would be best - people can rely on errorCode being set in all cases with no differing behaviour

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.