Last updated 2 years ago
Was this helpful?
⟩ ⟩ ⟩ ⟩ rethrow
⟩ ⟩ ⟩ rethrow
rethrows an unexpected error.
try { functionThatThrows(); } catch (err) { if (err instanceof InputError) { ... } else { throw err } // ⭐️ rethrow }
// custom Error class InputError extends Error {} // function that may throw function functionThatThrows() { // ... throw new InputError("Invalid input"); } try { functionThatThrows(); } catch (err) { if (err instanceof InputError) { ... } else { throw err } // ⭐️ rethrow }
Eloquent JavaScript ⟩ ⭐️
JavaScript: The Definitive Guide ⟩ 5.5.6 throw