1Exception::Assertion(3)User Contributed Perl DocumentatioEnxception::Assertion(3)
2
3
4
6 Exception::Assertion - Thrown when assertion failed
7
9 use Exception::Assertion;
10
11 sub assert_foo {
12 my $self = eval { $_[0]->isa(__PACKAGE__) } ? shift : __PACKAGE__;
13 my ($condition, $message) = @_;
14 Exception::Assertion->throw(
15 message => $message,
16 reason => 'foo failed',
17 ) unless $condition;
18 }
19
20 assert_foo( 0, 'assert_foo failed' );
21
23 This class extends standard Exception::Base and is thrown when
24 assertion is failed. It contains additional attribute "reason" which
25 represents detailed message about reason of failed assertion. The
26 exception has also raised verbosity.
27
29 ยท extends Exception::Base
30
32 ATTRS : HashRef
33 Declaration of class attributes as reference to hash.
34
35 See Exception::Base for details.
36
38 This class provides new attributes. See Exception::Base for other
39 descriptions.
40
41 reason : Str
42 Contains the additional message filled by assertion method.
43
44 message : Str = "Unknown assertion failed"
45 Contains the message of the exception. This class overrides the
46 default value from Exception::Base class.
47
48 verbosity : Int = 3
49 The default verbosity for assertion exception is raised to 3. This
50 class overrides the default value from Exception::Base class.
51
52 string_attributes : ArrayRef[Str] = ["message", "reason"]
53 Meta-attribute contains the format of string representation of
54 exception object. This class overrides the default value from
55 Exception::Base class.
56
58 Exception::Base, Test::Assertion.
59
61 Piotr Roszatycki <dexter@cpan.org>
62
64 Copyright (C) 2008, 2009 by Piotr Roszatycki <dexter@cpan.org>. This
65 program is free software; you can redistribute it and/or modify it
66 under the same terms as Perl itself.
67
68 See <http://www.perl.com/perl/misc/Artistic.html>
69
70
71
72perl v5.32.0 2020-07-28 Exception::Assertion(3)