feat(core): add onError hook

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-03-23 15:58:30 +01:00
committed by Braks
parent 87249e5dde
commit 8c3f54ec28
22 changed files with 250 additions and 180 deletions
+3 -2
View File
@@ -1,4 +1,5 @@
import type { CustomEvent, ElementData } from '~/types'
import { VueFlowError } from '~/utils/errors'
/**
* Access an edge
@@ -11,12 +12,12 @@ export default function useEdge<Data = ElementData, CustomEvents extends Record<
const edgeId = id ?? inject(EdgeId, '')
const edgeEl = inject(EdgeRef, null)
const { findEdge } = useVueFlow()
const { findEdge, emits } = useVueFlow()
const edge = findEdge<Data, CustomEvents>(edgeId)
if (!edge) {
throw new VueFlowError(`Edge with id ${edgeId} not found!`, 'useEdge')
emits.error(new VueFlowError(ErrorCode.EDGE_NOT_FOUND, edgeId))
}
return {