Skip to content

Commit 6e76f1c

Browse files
itsAlifitsAlif
itsAlif
authored and
itsAlif
committed
catch block sloution reorderd
1 parent 8b218eb commit 6e76f1c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/13-catch-blocks.solution.2.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ const tryCatchDemo = (state: "fail" | "succeed") => {
66
throw new Error("Failure!");
77
}
88
} catch (e) {
9-
if (e instanceof Error) {
10-
return e.message;
11-
}
9+
return (e as Error).message;
1210
}
1311
};
1412

src/13-catch-blocks.solution.3.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const tryCatchDemo = (state: "fail" | "succeed") => {
66
throw new Error("Failure!");
77
}
88
} catch (e) {
9-
return (e as Error).message;
9+
if (e instanceof Error) {
10+
return e.message;
11+
}
1012
}
1113
};
1214

0 commit comments

Comments
 (0)