class X::Attribute::NoPackage does X::MOP { }

Compile time error thrown when a required attribute is not assigned when creating an object.

For example

my class Uses-required {
    has $.req is required
};
my $object = Uses-required.new()

Dies with

OUTPUT: «(exit code 1The attribute '$!req' is requiredbut you did not provide a value for it.␤»

Methods§

method name§

method name(--> Str:D)

Returns the name of the attribute.

method why§

method why(--> Str:D)

Returns the reason why that attribute is required, and it will be included in the message if provided. That reason is taken directly from the is required trait.

my class Uses-required {
    has $.req is required("because yes")
};
my $object = Uses-required.new();                                  │
# OUTPUT: 
# «(exit code 1) The attribute '$!req' is required because because yes,␤ 
# but you did not provide a value for it.␤» 

Typegraph§

Type relations for X::Attribute::Required
raku-type-graph X::Attribute::Required X::Attribute::Required Exception Exception X::Attribute::Required->Exception MOP MOP X::Attribute::Required->MOP Mu Mu Any Any Any->Mu Exception->Any MOP->Any

Expand chart above