Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6e76f1c

Browse filesBrowse files
itsAlifitsAlif
itsAlif
authored and
itsAlif
committed
catch block sloution reorderd
1 parent 8b218eb commit 6e76f1c
Copy full SHA for 6e76f1c

File tree

2 files changed

+4
-4
lines changed
Filter options

2 files changed

+4
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/13-catch-blocks.solution.2.ts
+1-3Lines 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

Copy file name to clipboardExpand all lines: src/13-catch-blocks.solution.3.ts
+3-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.