1package Test2::Event::Exception; 2use strict; 3use warnings; 4 5our $VERSION = '1.302175'; 6 7 8BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } 9use Test2::Util::HashBase qw{error}; 10 11sub init { 12 my $self = shift; 13 $self->{+ERROR} = "$self->{+ERROR}"; 14} 15 16sub causes_fail { 1 } 17 18sub summary { 19 my $self = shift; 20 chomp(my $msg = "Exception: " . $self->{+ERROR}); 21 return $msg; 22} 23 24sub diagnostics { 1 } 25 26sub facet_data { 27 my $self = shift; 28 my $out = $self->common_facet_data; 29 30 $out->{errors} = [ 31 { 32 tag => 'ERROR', 33 fail => 1, 34 details => $self->{+ERROR}, 35 } 36 ]; 37 38 return $out; 39} 40 41 421; 43 44__END__ 45 46=pod 47 48=encoding UTF-8 49 50=head1 NAME 51 52Test2::Event::Exception - Exception event 53 54=head1 DESCRIPTION 55 56An exception event will display to STDERR, and will prevent the overall test 57file from passing. 58 59=head1 SYNOPSIS 60 61 use Test2::API qw/context/; 62 use Test2::Event::Exception; 63 64 my $ctx = context(); 65 my $event = $ctx->send_event('Exception', error => 'Stuff is broken'); 66 67=head1 METHODS 68 69Inherits from L<Test2::Event>. Also defines: 70 71=over 4 72 73=item $reason = $e->error 74 75The reason for the exception. 76 77=back 78 79=head1 CAVEATS 80 81Be aware that all exceptions are stringified during construction. 82 83=head1 SOURCE 84 85The source code repository for Test2 can be found at 86F<http://github.com/Test-More/test-more/>. 87 88=head1 MAINTAINERS 89 90=over 4 91 92=item Chad Granum E<lt>exodist@cpan.orgE<gt> 93 94=back 95 96=head1 AUTHORS 97 98=over 4 99 100=item Chad Granum E<lt>exodist@cpan.orgE<gt> 101 102=back 103 104=head1 COPYRIGHT 105 106Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>. 107 108This program is free software; you can redistribute it and/or 109modify it under the same terms as Perl itself. 110 111See F<http://dev.perl.org/licenses/> 112 113=cut 114