-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Error Capture Issue #5204
Comments
Maybe this is vue3 bug. But return promise doesn't make any sense for onSelect |
@tangjinzhou I updated above repo, added a custom component with custom event. Please help to check PageUsage <CustomComp @custom-event="onTest('custom')" /> CustomComp.vue<template>
<div class="custom-comp" @click="onClick">Click Me</div>
</template>
<script setup>
const props = defineProps({
onCustomEvent: Function,
});
// Style 1: return result, whatever it is sync or async function.
function onClick() {
return props.onCustomEvent();
}
// Style 2: use async/await, good for complex biz
// async function onClick() {
// await props.onCustomEvent();
// }
</script>
<style scoped>
.custom-comp {
width: 100px;
height: 50px;
background-color: green;
}
</style>
Thx |
if change function onClick() {
return props.onCustomEvent();
} to function onClick() {
props.onCustomEvent();
} we can not get onErrorCaptured. I donot know why. |
I believe there is code in try {
await onClick();
} catch (err) {
onErrorCaptured(err);
} so we need to keep the promise chain, try {
setTimeout(() => {
throw "this error can't be catched";
});
} catch (err) {
console.error(err);
} |
We do handle errors in ajax, but just Error stream like this:
if I do Kind of like middleware concept, |
@tangjinzhou |
Maybe we should use emit instead of props. But it involves too many places and cannot be completed in a short time. If you can, you can try pr |
function onClick() {
emit('custom-event', 'reject error');
console.log('this message will show before onErrorCaptured, and it always show up no matter emit fires error or not');
}
Yes, it is. So If I done the pr in weeks/months, there must be lots of conflicts with main branch. |
@tangjinzhou The PR is just for |
@tangjinzhou just FYI, after you refactor If I throw error in
|
Version
3.0.0-beta.8
Environment
MacOS 11.4, Chrome 97.0.4692.71, Vue 3.2.28
Reproduction link
https://github.com/gaokun/antdv-error-tracker
Steps to reproduce
see detail in reproduction demo
What is expected?
'onSelect' of Select should fire onErrorCaptured
What is actually happening?
it dosen't
I am not sure this is a bug or wrong usage.
If it is indeed a bug, it exsits in everywhere we invoke callbacks like this way 'props.onSelect()', it breaks the promise chain.
I am free to any feedback.
Thx
Ken
The text was updated successfully, but these errors were encountered: