We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a31fd4a commit d52c76eCopy full SHA for d52c76e
1 file changed
src/core/error/handle.ts
@@ -0,0 +1,20 @@
1
+import Jrror, { JoorError } from "@/core/error";
2
+import logger from "@/helpers/joorLogger";
3
+
4
+/**
5
+ * Handles errors by checking their type and calling the appropriate method.
6
+ * If the error is not an instance of Jrror or JoorError, it logs the error.
7
+ *
8
+ * @param {unknown} error - The error to handle.
9
10
+ * Meant to reduce code duplication while handling errors in the codebase.
11
+ */
12
+function handleError(error: unknown): void {
13
+ if (error instanceof Jrror || error instanceof JoorError) {
14
+ error.handle();
15
+ } else {
16
+ logger.error(error);
17
+ }
18
+}
19
20
+export default handleError;
0 commit comments