Need Assistance?

support@tutorialshub.in

Async TypeScript, Modules & Declarations

Safe Error Handling in catch Blocks

ADVERTISEMENT
TypeScript Free Lesson
5 min read
ADVERTISEMENT

In strict TypeScript, the error caught in catch (err) has type unknown (because JavaScript lets you throw anything, not just Error objects). Always check err instanceof Error before reading err.message.

ADVERTISEMENT
Hi, I'm Tuby! Here to help you