Exception handling syntax: Difference between revisions

Content deleted Content added
See also: MOS:COMMENT add. WP:CATEGORYs: adds, cut redundant.
Toastal (talk | contribs)
Add ATS’s exception handling
Line 48:
{{Further|Assembly language}}
Most assembly languages will have a macro instruction or an interrupt address available for the particular system to intercept events such as illegal op codes, program check, data errors, overflow, [[divide by zero]], and other such. IBM and Univac mainframes had the [[STXIT]] macro. [[Digital Equipment Corporation]] [[RT11]] systems had trap vectors for program errors, i/o interrupts, and such. [[DOS]] has certain interrupt addresses. [[Microsoft Windows]] has specific module calls to trap program errors.
 
=== ATS ===
{{Further|ATS (programming language)}}
 
<syntaxhighlight lang="ats">
exception MyException of (string, int) (* exceptions can carry a value *)
 
implement main0 (): void =
try $raise MyException("not enough food", 2) with
| ~MyException(s, i) => begin
$extfcall(void, "fprintf", stderr_ref, "%s: %d", s, i);
fileref_close(stderr_ref);
end
</syntaxhighlight>
 
=== Bash ===