Skip to content

Commit d3e7317

Browse files
committed
chore: add hooks(useError).
1 parent 435727a commit d3e7317

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/hooks/useError.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { watchEffect } from 'vue';
2+
3+
type UseErrorOptions = {
4+
emitListener: boolean;
5+
};
6+
7+
export default function useError(message: string, { emitListener }: UseErrorOptions) {
8+
const emit = () => {
9+
throw new Error(`[VueJsonPretty] ${message}`);
10+
};
11+
12+
watchEffect(() => {
13+
if (emitListener) {
14+
emit();
15+
}
16+
});
17+
18+
return {
19+
emit,
20+
};
21+
}

0 commit comments

Comments
 (0)