Skip to content

Commit 865fe72

Browse files
committed
docs: update troubleshooting page
1 parent 7f2917a commit 865fe72

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

docs/src/guide/troubleshooting.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,34 @@ const edges = ref([
101101

102102
## Evaluating Errors During Runtime
103103

104-
During development, Vue Flow emits warnings to the console for errors encountered. These warnings are intended to help developers identify and resolve issues without failing silently. In production, however, these warnings are suppressed to avoid exposing potentially sensitive information to end users.
104+
During development, Vue Flow emits warnings to the console for errors encountered.
105+
These warnings are intended to help developers identify and resolve issues without failing silently.
106+
In production, however, these warnings are suppressed.
105107

106-
### Hooking into onError or @error Events
108+
### Handling Errors
107109

108-
You can handle errors programmatically by hooking into the `onError` or `@error` events. This allows you to perform custom operations based on the type of error encountered. Here's an example of how to use `isErrorOfType` to handle a specific error type:
110+
You can handle errors by hooking into the `onError` event.
111+
This allows you to perform custom operations based on the type of error encountered.
112+
Here's an example of how to use the `isErrorOfType` utility to handle an error of `NODE_INVALID` type.
109113

110-
```ts
111-
import { isErrorOfType, ErrorCode } from '@vue-flow/core'
114+
```vue
115+
<script lang="ts" setup>
116+
import { isErrorOfType, ErrorCode, useVueFlow, VueFlowError, VueFlow } from '@vue-flow/core'
117+
118+
const { onError } = useVueFlow()
119+
120+
onError(handleError)
112121
113-
onError((error) => {
122+
function handleError(error: VueFlowError) {
114123
if (isErrorOfType(error, ErrorCode.NODE_INVALID)) {
115124
const [nodeId] = error.args
116-
// Handle the NODE_INVALID error, e.g., by notifying the user or logging details.
125+
// handle the error
117126
}
118-
})
119-
```
127+
}
128+
</script>
120129
121-
```vue
122130
<template>
123-
<VueFlow v-model="elements" @error="handleError" />
131+
<VueFlow @error="handleError" />
124132
</template>
125133
```
126134

127-

0 commit comments

Comments
 (0)