Not possible to easily extract offending edge/node ID from VueFlowError #1277
Locked
snoozbuster
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Not a bug but a feature request, so I'm moving it to discussions. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Would something like this work for you? import { ErrorCode, isErrorOfType } from '@vue-flow/core'
const { onError } = useVueFlow()
onError((err) => {
// typeguard to assert the type of the args provided by the error - if you're not using TS, this step is not necessary and would just be the same as doing `error.code === ErrorCode.EDGE_INVALID`
if (isErrorOfType(err, ErrorCode.EDGE_INVALID) {
const [id] = err.args
console.log(id) // 'e1-2'
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Current Behavior
When a VueFlowError is instantiated, a reference to the offending edge ID is passed. This is used to generate an error message but the value itself is not stored on the error, either in a custom property or in the
cause
property of the error. This makes string parsing the only way to extract the offending edge/node/etc, instead of simply accessing it off the error object, which makes error handling of the type mentioned in this comment quite challenging/error-prone.Expected Behavior
The error should expose all relevant information for programmatic access.
Steps To Reproduce
Beta Was this translation helpful? Give feedback.
All reactions