Comments (4)
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.
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.
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.
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)
- `<script setup generic>` throws TypeScript error when using prop defaults HOT 2
- `onUnmounted` doesn't run if slot content is wrapped in a div (within this tab structure)
- chain computed lost reactivity when computed effect happens HOT 2
- Attribute stringification HOT 16
- with side-effect computed will cause an infinite loop when it returns different values in each run
- Hydration warning SSR on style using v-bind in SFC together with :style attribute
- Hydration mismatch when adding a class in the directive
- There are many Detached XXX in the Memory panel of Google Chrome's devtools
- After vue update, vue-tsc generates: "TypeError: (0 , language_core_1.buildMappings) is not a function" HOT 5
- hooks中export一个函数,函数return一个ref对象,value是字符串类型,template使用时会莫名多出双引号 Export a function in hooks, which returns a ref object with value being a string type. When using template, double quotes will inexplicably appear
- 使用h函数和render函数挂载组件,组件引用的全局UI组件无法正常解析渲染 HOT 4
- Broken inline comments within explicit undefined bindings
- Run-time error in @vue/compiler-core - all versions after 3.4.25 HOT 2
- `watchSyncEffect` causes the Maximum call stack size to exceeded. HOT 10
- when using `withModifiers`, the `capture` modifier is ineffective. HOT 2
- Functional components cannot respond to slot switching. ( 函数式组件无法响应 slot 的切换 )
- Optimization of computed value is not working any more HOT 1
- Conditional children inside an optional Teleport (with disabled) doesn't work
- In certain cases, the view fails to update properly
- Computed value didn't update HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.