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.48
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
57 The source code repository for Specio can be found at
58 <https://github.com/houseabsolute/Specio>.
59
61 Dave Rolsky <autarch@urth.org>
62
64 This software is Copyright (c) 2012 - 2022 by Dave Rolsky.
65
66 This is free software, licensed under:
67
68 The Artistic License 2.0 (GPL Compatible)
69
70 The full text of the license can be found in the LICENSE file included
71 with this distribution.
72
73
74
75perl v5.36.0 2023-01-20 Specio::Exception(3)