Rules / Types, classes & roles / exception

X::NYI Reference

Error due to use of an unimplemented feature

What it is #

Position in the hierarchy #

Inherits from
Does
Inherited byX::Comp::NYI

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method new #

method new( :$feature, :$did-you-mean, :$workaround)

This is the default constructor for X:NYI which can take three parameters with obvious meanings. In this case, we are throwing an exception that indicates that the ventured routine has not been implemented; we use the generic &?ROUTINE.name to not tie the exception to the method name in case it is changed later on. This code effectively throws this exception Using the exception properties, it composes the message that we see there.

method feature #

Returns a Str describing the missing feature.

method did-you-mean #

Returns a Str indicating the optional feature that is already implemented.

method workaround #

It helpfully shows a possible workaround for the missing feature, if it's been declared.

method message #

Returns the message including the above properties.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

4 no-output

class X::NYI is Exception { }

Not executed: the documentation states no expected output for this example.

HyperWhatever is not yet implemented. Sorry.

Not executed: the documentation states no expected output for this example.

class Nothing {
method ventured( $sub, **@args) {
    X::NYI.new( feature => &?ROUTINE.name,
                did-you-mean => "gained",
                workaround => "Implement it yourself" ).throw;
}
}

my $nothing = Nothing.new;
$nothing.ventured("Nothing", "Gained");

Not executed: the documentation states no expected output for this example.

# OUTPUT:
# ventured not yet implemented. Sorry.
# Did you mean: gained?
# Workaround: Implement it yourself
#   in method ventured at NYI.raku line 6
#   in block <unit> at NYI.raku line 14

Not executed: the documentation states no expected output for this example.