Skip to content
Custom Error Classes
step 1/5

Reading — step 1 of 5

Learn

~1 min readError Handling

For complex apps, distinguish error types with subclasses of Error:

js

Then instanceof lets callers handle different types differently:

js

Always set this.name in the constructor — it's used in stack traces and err.toString().

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…