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 );
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.
25
27 ยท Exception::Base
28
30 ATTRS
31 Declaration of class attributes as reference to hash.
32
33 See Exception::Base for details.
34
36 This class provides new attributes. See Exception::Base for other
37 descriptions.
38
39 message : Str = "Unknown assertion failed" {rw}
40 Contains the message of the exception. This class overrides the
41 default value from Exception::Base class.
42
43 verbosity : Int = 3 {rw}
44 The default verbosity for assertion exception is raised to 3. This
45 class overrides the default value from Exception::Base class.
46
47 reason : Str {rw}
48 Contains the additional message filled by assertion method.
49
50 string_attributes : ArrayRef = ['message', 'reason']
51 Meta-attribute contains the format of string representation of
52 exception object. This class overrides the default value from
53 Exception::Base class.
54
56 Exception::Base, Test::Assertion.
57
59 If you find the bug, please report it.
60
62 Piotr Roszatycki <dexter@debian.org>
63
65 Copyright (C) 2008, 2009 by Piotr Roszatycki <dexter@debian.org>.
66
67 This program is free software; you can redistribute it and/or modify it
68 under the same terms as Perl itself.
69
70 See <http://www.perl.com/perl/misc/Artistic.html>
71
72
73
74perl v5.12.0 2010-05-06 Exception::Assertion(3)