Skip to content

Commit cf222bc

Browse files
committed
[docs] add some documentation on how to introduce typed exceptions
1 parent 86b4827 commit cf222bc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/exceptions.pod

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
=head1 Introducing Typed Exceptions
2+
3+
For a Perl 6 compiler to support typed exceptions properly,
4+
the following steps must be taken:
5+
6+
=head2 Basic types
7+
8+
The compiler writer needs to implement the types C<Exception>, C<Backtrace>
9+
C<X::AdHoc> and C<X::Comp>, as described in S32::Exception.
10+
11+
=head2 Exception type mapping
12+
13+
When the compiler passes an exception object to the user space (ie C<$!> and
14+
inside a C<CATCH> block also C<$_>), it needs to make sure that the type
15+
conforms to type C<Exception>, wrapping it in C<X::AdHoc> if that is not the
16+
case.
17+
18+
Exceptions from non-Perl 6 sources should be boxed into a Perl 6 Str as the
19+
payload of an C<X::AdHoc> object.
20+
21+
=head2 Importing other exception types
22+
23+
The next step is to import the exception classes and roles from S32::Exception
24+
25+
=head2 Compile time exceptions
26+
27+
The compiler needs to provide the named C<filename>, C<line> and C<column>
28+
arguments to the constructor of the exceptions thrown from within the compiler
29+
(TODO: TimToady wants a characters offset, not (just) line and column).
30+
31+
=cut

0 commit comments

Comments
 (0)