Can you throw multiple errors in a single `throw` statement?

Responsive Ad Header

Question

Grade: Education Subject: Support
Can you throw multiple errors in a single `throw` statement?
Asked by:
60 Viewed 60 Answers
Responsive Ad After Question

Answer (60)

Best Answer
(298)
Yes, you can throw multiple errors in a single `throw` statement by creating multiple error objects and passing them as arguments to the `throw` statement. For example, `throw new Error('First error', {code: 1001}); throw new Error('Second error', {code: 1002});` throws two separate error objects.