1Specio::Exception(3) User Contributed Perl Documentation Specio::Exception(3)
2
3
4
6 Specio::Exception - An exception class for type constraint failures
7
9 version 0.47
10
12 use Try::Tiny;
13
14 try {
15 $type->validate_or_die($value);
16 }
17 catch {
18 if ( $_->isa('Specio::Exception') ) {
19 print $_->message, "\n";
20 print $_->type->name, "\n";
21 print $_->value, "\n";
22 }
23 };
24
26 This exception class is thrown by Specio when a type check fails. It
27 emulates the Throwable::Error API, but doesn't use that module to avoid
28 adding a dependency on Moo.
29
31 This class provides the following methods:
32
33 $exception->message
34 The error message associated with the exception.
35
36 $exception->stack_trace
37 A Devel::StackTrace object for the exception.
38
39 $exception->type
40 The type constraint object against which the value failed.
41
42 $exception->value
43 The value that failed the type check.
44
45 $exception->as_string
46 The exception as a string. This includes the method and the stack
47 trace.
48
50 This class overloads stringification to call the "as_string" method.
51
53 Bugs may be submitted at
54 <https://github.com/houseabsolute/Specio/issues>.
55
56 I am also usually active on IRC as 'autarch' on "irc://irc.perl.org".
57
59 The source code repository for Specio can be found at
60 <https://github.com/houseabsolute/Specio>.
61
63 Dave Rolsky <autarch@urth.org>
64
66 This software is Copyright (c) 2012 - 2021 by Dave Rolsky.
67
68 This is free software, licensed under:
69
70 The Artistic License 2.0 (GPL Compatible)
71
72 The full text of the license can be found in the LICENSE file included
73 with this distribution.
74
75
76
77perl v5.34.0 2022-01-21 Specio::Exception(3)