JS ⟩ statement ⟩ control flow ⟩ jump ⟩ rethrow
JS ⟩ error ⟩ handling ⟩ 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 ⟩ Selective Catching ⭐️
JavaScript: The Definitive Guide ⟩ 5.5.6 throw
throw
Last updated 1 year ago