=begin pod :kind("Type") :subkind("class") :category("exception")

=TITLE class X::Attribute::Required

=SUBTITLE Compilation error due to not declaring an attribute with the C<is required> trait

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

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

For example

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

Dies with

=for code :lang<text>
OUTPUT: «(exit code 1) The attribute '$!req' is required, but you did not provide a value for it.␤»

=head1 Methods

=head2 method name

    method name(--> Str:D)

Returns the name of the attribute.

=head2 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 C<is required>
trait.

=for code :skip-test<compile time error>
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.␤»



=end pod
