| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
throw Statement (JavaScript) | Microsoft Docs |
01/18/2017 |
windows-client-threshold |
|
language-reference |
|
|
|
75cbade0-fb81-4ffe-b187-b71be380bb05 |
14 |
mikejo5000 |
mikejo |
ghogen |
Generates an error condition that can be handled by a try...catch...finally statement.
throw exception
The required exception argument can be any expression.
The following example throws an error inside a try block, and it is caught in the catch block.
try {
throw new Error(200, "x equals zero");
}
catch (e) {
document.write(e.message);
}
// Output: x equals zero.
[!INCLUDEjsv5]