Syntax
Raises an error that the nearest enclosing CATCH receives. Without a CATCH, the program stops at that line.
THROW <value>Parts
| <value> | A string, a number, or a record with a message field and an optional code field. A string or number becomes the message. A record gives its message and code. |
|---|
Good to know
THROWwithout a value is a compile error: "THROW requires a value".- The error leaves every function on the way until a CATCH takes it, so a function can throw and its caller can catch.
- The
nameof a thrown error is alwaysError. Thecodeis""unless a record gave one. - Do not
THROWthe error you caught: thenamebecomesErrorand thecommandis lost. UseRETHROWto pass it on unchanged. - A
THROWinside a task does not stop the program. It marks the task as failed, and the error comes back atAWAITTASKorTaskResult().