You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the default constructor for C<X:NYI> which can take three parameters with obvious meanings.
31
+
32
+
=begincode
33
+
class Nothing {
34
+
method ventured( $sub, **@args) {
35
+
X::NYI.new( feature => &?ROUTINE.name,
36
+
did-you-mean => "gained",
37
+
workaround => "Implement it yourself" ).throw;
38
+
}
39
+
}
40
+
41
+
my $nothing = Nothing.new;
42
+
$nothing.ventured("Nothing", "Gained");
43
+
=endcode
44
+
45
+
In this case, we are throwing an exception that indicates that the C<ventured> routine has not been implemented; we use the generic C<&?ROUTINE.name> to not tie the exception to the method name in case it is changed later on. This code effectively throws this exception
46
+
47
+
=begincode
48
+
# OUTPUT:
49
+
# ventured not yet implemented. Sorry.
50
+
# Did you mean: gained?
51
+
# Workaround: Implement it yourself
52
+
# in method ventured at NYI.p6 line 6
53
+
# in block <unit> at NYI.p6 line 14
54
+
=endcode
55
+
56
+
Using the exception properties, it composes the message that we see there.
57
+
58
+
=head2method feature
27
59
28
60
Returns a C<Str> describing the missing feature.
29
61
62
+
=head2method did-you-mean
63
+
64
+
Returns a C<Str> indicating the optional feature that is already implemented.
65
+
66
+
=head2method workaround
67
+
68
+
It helpfully shows a possible workaround for the missing feature, if it's been declared.
69
+
70
+
=head2method message
71
+
72
+
Returns the message including the above properties.
0 commit comments