| 1 | package DBIx::Class::Async::Exception::Factory; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 102 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 102 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 102 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 102 | our $VERSION = qv('v1.2.0'); | |||||||||||||||||||||||||||||||||||||||||
| 8 | 102 | our $AUTHORITY = 'cpan:MANWAR'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 102 | ▶ | use DBIx::Class::Async::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 102 | ▶ | use DBIx::Class::Async::Exception::RelationshipAsColumn; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 102 | ▶ | use DBIx::Class::Async::Exception::NotInStorage; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 102 | ▶ | use DBIx::Class::Async::Exception::MissingColumn; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 102 | ▶ | use DBIx::Class::Async::Exception::NoSuchRelationship; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 102 | ▶ | use DBIx::Class::Async::Exception::AmbiguousColumn; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | DBIx::Class::Async::Exception::Factory - Translate raw DBIx::Class errors into typed exception objects | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | Version v1.2.0 | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | use DBIx::Class::Async::Exception::Factory; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | try { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # ... async DBIC operation ... | ||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | catch { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # Translates the raw string error into the right typed subclass, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # then re-throws it. | ||||||||||||||||||||||||||||||||||||||||||
| 36 | DBIx::Class::Async::Exception::Factory->throw_from_dbic_error( | ||||||||||||||||||||||||||||||||||||||||||
| 37 | error => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | schema => $self->schema, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | result_class => $result_class, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | operation => $operation, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | This factory inspects raw L<DBIx::Class> exception strings, matches them | ||||||||||||||||||||||||||||||||||||||||||
| 47 | against known error patterns, and throws the appropriate | ||||||||||||||||||||||||||||||||||||||||||
| 48 | L<DBIx::Class::Async::Exception> subclass. If no pattern matches, it wraps | ||||||||||||||||||||||||||||||||||||||||||
| 49 | the error in the base L<DBIx::Class::Async::Exception> so callers always | ||||||||||||||||||||||||||||||||||||||||||
| 50 | receive a structured object rather than a plain string. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # Pattern Table | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # Each entry: match regex, exception class, builder sub | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | my @PATTERNS = ( | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # relationship name passed where a column was expected | ||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | class => 'DBIx::Class::Async::Exception::RelationshipAsColumn', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | match => qr/No such column '(\w+)' on (\S+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | my ($col, $raw_source) = @{$p{captures}}; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my ($rel_type) = _rel_type($p{schema}, $raw_source, $col); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | my $is_rel = defined $rel_type; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | return () unless $is_rel; # let fallback handle genuine unknown columns | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 75 | message => _fmt_message( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | "Relationship '$col' passed where a column name was expected on $raw_source" | ||||||||||||||||||||||||||||||||||||||||||
| 77 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 78 | relationship => $col, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | relationship_type => $rel_type, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | source_class => $p{result_class} // $raw_source, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | hint => _rel_hint($col, $p{operation}), | ||||||||||||||||||||||||||||||||||||||||||
| 83 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$p{"result_class"} // $raw_source
MC/DC0%0/2
$p{"result_class"} // $raw_source
$p{"result_class"}
$raw_source
Truth table33%1/3
A // B
A= $p{"result_class"}B= $raw_source
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # Genuinely unknown column (not a relationship -- fallthrough from above) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | class => 'DBIx::Class::Async::Exception', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | match => qr/No such column '(\w+)' on (\S+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my ($col, $raw_source) = @{$p{captures}}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 96 | message => _fmt_message("No such column '$col' on $raw_source"), | ||||||||||||||||||||||||||||||||||||||||||
| 97 | source_class => $p{result_class} // $raw_source, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | hint => "Check that '$col' is declared with add_columns() on $raw_source.", | ||||||||||||||||||||||||||||||||||||||||||
| 100 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$p{"result_class"} // $raw_source
MC/DC0%0/2
$p{"result_class"} // $raw_source
$p{"result_class"}
$raw_source
Truth table33%1/3
A // B
A= $p{"result_class"}B= $raw_source
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | # update/delete on a row not yet inserted | ||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | class => 'DBIx::Class::Async::Exception::NotInStorage', | ||||||||||||||||||||||||||||||||||||||||||
| 108 | match => qr/Unable to perform (\w+) .* not in_storage/i, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my ($op) = @{$p{captures}}; | |||||||||||||||||||||||||||||||||||||||||
| 112 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 113 | message => _fmt_message("Cannot $op a row that has not been inserted (in_storage is false)"), | ||||||||||||||||||||||||||||||||||||||||||
| 114 | row_class => $p{result_class}, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | operation => $op, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | hint => "Call insert() or create() before calling $op().", | ||||||||||||||||||||||||||||||||||||||||||
| 117 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 119 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | # Missing required column on insert | ||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | class => 'DBIx::Class::Async::Exception::MissingColumn', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | match => qr/Missing value for required column '(\w+)'/, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my ($col) = @{$p{captures}}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 130 | message => _fmt_message("Required column '$col' was not provided"), | ||||||||||||||||||||||||||||||||||||||||||
| 131 | column => $col, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | source_class => $p{result_class}, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | hint => "Add '$col' to your insert/create hashref.", | ||||||||||||||||||||||||||||||||||||||||||
| 135 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 137 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 138 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # No such relationship in join/prefetch | ||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | class => 'DBIx::Class::Async::Exception::NoSuchRelationship', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | match => qr/No such relationship (\w+) on (\S+)/, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my ($rel, $raw_source) = @{$p{captures}}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 148 | message => _fmt_message("No relationship '$rel' on $raw_source"), | ||||||||||||||||||||||||||||||||||||||||||
| 149 | relationship => $rel, | ||||||||||||||||||||||||||||||||||||||||||
| 150 | source_class => $p{result_class} // $raw_source, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | hint => "Check that '$rel' is declared with has_many(), belongs_to(), or might_have() on $raw_source.", | ||||||||||||||||||||||||||||||||||||||||||
| 153 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$p{"result_class"} // $raw_source
MC/DC0%0/2
$p{"result_class"} // $raw_source
$p{"result_class"}
$raw_source
Truth table0%0/3
A // B
A= $p{"result_class"}B= $raw_source
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | # Ambiguous column in multi-table query | ||||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | class => 'DBIx::Class::Async::Exception::AmbiguousColumn', | ||||||||||||||||||||||||||||||||||||||||||
| 161 | match => qr/Column '(\w+)' in (?:field|order|group|where) clause is ambiguous/i, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | my ($col) = @{$p{captures}}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 166 | message => _fmt_message("Ambiguous column '$col' -- it exists in multiple joined tables"), | ||||||||||||||||||||||||||||||||||||||||||
| 167 | column => $col, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | source_class => $p{result_class}, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | hint => "Qualify the column: use 'me.$col' for the primary table or 'relname.$col' for a join.", | ||||||||||||||||||||||||||||||||||||||||||
| 171 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | # HAVING clause without GROUP BY, produced when DBIC generates | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # a DELETE subquery from a ResultSet that has group_by/having attributes | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # and silently drops the GROUP BY. DBIx::Class::Async routes such | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # deletes through delete_all (fetch PKs first, then DELETE by PK) so | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # this error should not occur in normal use, but may still arrive from | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # raw worker errors or from callers constructing queries outside the | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # standard ResultSet API. | ||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | class => 'DBIx::Class::Async::Exception', | ||||||||||||||||||||||||||||||||||||||||||
| 185 | match => qr/HAVING clause(?: is)? (?:used )?without (?:a )?GROUP BY/i, | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | build => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my (%p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 188 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 189 | message => _fmt_message( | ||||||||||||||||||||||||||||||||||||||||||
| 190 | "HAVING clause used without GROUP BY -- this is usually caused by " | ||||||||||||||||||||||||||||||||||||||||||
| 191 | . "deleting from a ResultSet that has group_by/having attributes " | ||||||||||||||||||||||||||||||||||||||||||
| 192 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 193 | source_class => $p{result_class}, | ||||||||||||||||||||||||||||||||||||||||||
| 194 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | hint => "Use delete_all() instead of delete() when your ResultSet " | ||||||||||||||||||||||||||||||||||||||||||
| 196 | . "has group_by or having attributes, or call search() with " | ||||||||||||||||||||||||||||||||||||||||||
| 197 | . "only group_by/having before counting/aggregating rather " | ||||||||||||||||||||||||||||||||||||||||||
| 198 | . "than deleting.", | ||||||||||||||||||||||||||||||||||||||||||
| 199 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 201 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 202 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 102 | ); | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | =head2 throw_from_dbic_error | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | DBIx::Class::Async::Exception::Factory->throw_from_dbic_error( | ||||||||||||||||||||||||||||||||||||||||||
| 211 | error => $raw_error_string, # required | ||||||||||||||||||||||||||||||||||||||||||
| 212 | schema => $schema, # optional, enables relationship detection | ||||||||||||||||||||||||||||||||||||||||||
| 213 | result_class => $result_class, # optional, e.g. 'My::Schema::Result::Foo' | ||||||||||||||||||||||||||||||||||||||||||
| 214 | operation => $operation, # optional, e.g. 'update_or_create' | ||||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | Matches C<error> against known DBIC error patterns and throws the appropriate | ||||||||||||||||||||||||||||||||||||||||||
| 218 | L<DBIx::Class::Async::Exception> subclass. If no pattern matches, wraps the | ||||||||||||||||||||||||||||||||||||||||||
| 219 | raw string in the base L<DBIx::Class::Async::Exception> and throws that. | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | Always throws -- never returns. | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 13 | ▶ | sub throw_from_dbic_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw_from_dbic_error: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 13 | my ($class, %p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 13 | ▶ | my $error = $p{error} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$p{"error"} // ""
MC/DC0%0/1
$p{"error"} // ""
$p{"error"}
Truth table50%1/2
A
A= $p{"error"}
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | # If already one of ours, re-throw as-is | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 13 | ▶ | if ( ref $error && $error->isa('DBIx::Class::Async::Exception') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $error and $error->isa("DBIx::Class::Async::Exception")
MC/DC100%2/2
ref $error and $error->isa("DBIx::Class::Async::Exception")
ref $error
$error->isa("DBIx::Class::Async::Exception")
Truth table100%3/3
A and B
A= ref $errorB= $error->isa("DBIx::Class::Async::Exception")
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | $error->rethrow; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | # stringify if it's some other object (e.g. DBIx::Class::Exception) | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 12 | ▶ | $error = "$error" if ref $error; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 12 | for my $rule (@PATTERNS) { | |||||||||||||||||||||||||||||||||||||||||
| 239 | 62 | ▶ | if ( my @captures = ($error =~ $rule->{match}) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | my %args = eval { | |||||||||||||||||||||||||||||||||||||||||
| 241 | 6 | $rule->{build}->( | |||||||||||||||||||||||||||||||||||||||||
| 242 | %p, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | error => $error, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | captures => \@captures, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 6 | ▶ | next if $@ || !%args; # build failed or returned empty -- try next pattern | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ or not %args
MC/DC50%1/2
$@ or not %args
$@
not %args
Truth table66%2/3
A or not(B)
A= $@B= not %args
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 5 | $rule->{class}->throw(%args); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | return; # unreachable, but explicit | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | # No pattern matched -- wrap in base exception | ||||||||||||||||||||||||||||||||||||||||||
| 255 | DBIx::Class::Async::Exception->throw( | ||||||||||||||||||||||||||||||||||||||||||
| 256 | message => _fmt_message($error), | ||||||||||||||||||||||||||||||||||||||||||
| 257 | original_error => $error, | ||||||||||||||||||||||||||||||||||||||||||
| 258 | operation => $p{operation}, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | source_class => $p{result_class}, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | =head2 make_from_dbic_error | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | my $exception = DBIx::Class::Async::Exception::Factory->make_from_dbic_error(%args); | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | Like L</throw_from_dbic_error> but returns the exception object instead of | ||||||||||||||||||||||||||||||||||||||||||
| 268 | throwing it. Useful when you need to attach the exception to a failed Future | ||||||||||||||||||||||||||||||||||||||||||
| 269 | rather than die-ing directly. | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 7 | ▶ | sub make_from_dbic_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_from_dbic_error: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 7 | my ($class, %p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 7 | my $exception; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 7 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 278 | 7 | $class->throw_from_dbic_error(%p); | |||||||||||||||||||||||||||||||||||||||||
| 279 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 7 | $exception = $@; | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | # Paranoia: if something went wrong in throw itself, wrap it | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 7 | ▶ | unless ( ref $exception && $exception->isa('DBIx::Class::Async::Exception') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $exception and $exception->isa("DBIx::Class::Async::Exception")
MC/DC0%0/2
ref $exception and $exception->isa("DBIx::Class::Async::Exception")
ref $exception
$exception->isa("DBIx::Class::Async::Exception")
Truth table33%1/3
A and B
A= ref $exceptionB= $exception->isa("DBIx::Class::Async::Exception")
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | $exception = DBIx::Class::Async::Exception->new( | ||||||||||||||||||||||||||||||||||||||||||
| 285 | message => "Exception factory failed: $exception", | ||||||||||||||||||||||||||||||||||||||||||
| 286 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 7 | return $exception; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | =head2 validate_or_fail | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | my $exception = DBIx::Class::Async::Exception::Factory->validate_or_fail( | ||||||||||||||||||||||||||||||||||||||||||
| 296 | args => \%hashref, # the create/update hashref | ||||||||||||||||||||||||||||||||||||||||||
| 297 | schema => $schema, # DBIx::Class::Schema instance or class name | ||||||||||||||||||||||||||||||||||||||||||
| 298 | result_class => $result_class, # e.g. 'My::Schema::Result::Operation' | ||||||||||||||||||||||||||||||||||||||||||
| 299 | operation => $operation, # e.g. 'update_or_create' | ||||||||||||||||||||||||||||||||||||||||||
| 300 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | return Future->fail($exception) if $exception; | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | Pre-flight check intended for use in C<_call_worker> before dispatching to the | ||||||||||||||||||||||||||||||||||||||||||
| 304 | worker process. Inspects C<args> for relationship keys with C<undef> values and | ||||||||||||||||||||||||||||||||||||||||||
| 305 | returns a L<DBIx::Class::Async::Exception::RelationshipAsColumn> object if one | ||||||||||||||||||||||||||||||||||||||||||
| 306 | is found, or C<undef> if the args look clean. | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | Returns an exception object rather than throwing, so the caller can decide how | ||||||||||||||||||||||||||||||||||||||||||
| 309 | to surface it -- typically as C<< Future->fail($exception) >> to keep error | ||||||||||||||||||||||||||||||||||||||||||
| 310 | handling consistent with the rest of the async pipeline. | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 519 | ▶ | sub validate_or_fail { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_or_fail: called CC=14 SCAR=34.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 519 | my ($class, %p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 519 | ▶ | my $args = $p{args} or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 519 | ▶ | my $schema = $p{schema} or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 519 | ▶ | my $result_class = $p{result_class} or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 519 | ▶ | return unless ref($args) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # schema may be a class name string rather than a connected object | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 519 | ▶ | my $schema_obj = ref($schema) ? $schema : eval { $schema->connect } or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 519 | ▶ | my $source = _find_source($schema_obj, $result_class) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 519 | for my $key (keys %$args) { | |||||||||||||||||||||||||||||||||||||||||
| 329 | 1452 | ▶ | next if defined $args->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 36 | ▶ | next unless $source->has_relationship($key); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $rel_info = $source->relationship_info($key); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | my $rel_type = $rel_info ? ($rel_info->{attrs}{accessor} // 'multi') : 'relationship'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$rel_info->{"attrs"}{"accessor"} // "multi"
MC/DC0%0/1
$rel_info->{"attrs"}{"accessor"} // "multi"
$rel_info->{"attrs"}{"accessor"}
Truth table0%0/2
A
A= $rel_info->{"attrs"}{"accessor"}
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | my $op = $p{operation} // 'operation'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$p{"operation"} // "operation"
MC/DC0%0/1
$p{"operation"} // "operation"
$p{"operation"}
Truth table0%0/2
A
A= $p{"operation"}
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | return DBIx::Class::Async::Exception::RelationshipAsColumn->new( | |||||||||||||||||||||||||||||||||||||||||
| 337 | message => _fmt_message( | ||||||||||||||||||||||||||||||||||||||||||
| 338 | "Relationship '$key' passed as undef in ${op}() on $result_class" | ||||||||||||||||||||||||||||||||||||||||||
| 339 | . " -- omit the key if you have no related rows to insert" | ||||||||||||||||||||||||||||||||||||||||||
| 340 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 341 | relationship => $key, | ||||||||||||||||||||||||||||||||||||||||||
| 342 | relationship_type => $rel_type, | ||||||||||||||||||||||||||||||||||||||||||
| 343 | source_class => $result_class, | ||||||||||||||||||||||||||||||||||||||||||
| 344 | operation => $op, | ||||||||||||||||||||||||||||||||||||||||||
| 345 | hint => "Omit '$key' from the hashref entirely if there are no " | ||||||||||||||||||||||||||||||||||||||||||
| 346 | . "related rows to insert. To insert related rows, pass an " | ||||||||||||||||||||||||||||||||||||||||||
| 347 | . "arrayref of hashrefs: $key => [\\%related_data].", | ||||||||||||||||||||||||||||||||||||||||||
| 348 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 519 | return; # no issues found | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | # | ||||||||||||||||||||||||||||||||||||||||||
| 355 | # | ||||||||||||||||||||||||||||||||||||||||||
| 356 | # Private Helpers | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 12 | ▶ | sub _fmt_message { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fmt_message: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 12 | my ($msg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 12 | return "[DBIx::Class::Async] $msg"; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | ▶ | sub _rel_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type: called CC=8 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 3 | my ($schema, $raw_source_class, $rel_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 3 | ▶ | return unless $schema && $raw_source_class && $rel_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$schema and $raw_source_class and $rel_name
$schema and $raw_source_class
MC/DC0%0/3
$schema and $raw_source_class and $rel_name
$schema
$raw_source_class
$rel_name
Truth table25%1/4
A and B and C
A= $schemaB= $raw_source_classC= $rel_name
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 3 | ▶ | my $source = _find_source($schema, $raw_source_class) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 3 | ▶ | return unless $source->has_relationship($rel_name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | my $info = $source->relationship_info($rel_name); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | ▶ | return $info ? ($info->{attrs}{accessor} // 'multi') : 'relationship'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$info->{"attrs"}{"accessor"} // "multi"
MC/DC0%0/1
$info->{"attrs"}{"accessor"} // "multi"
$info->{"attrs"}{"accessor"}
Truth table50%1/2
A
A= $info->{"attrs"}{"accessor"}
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 522 | ▶ | sub _find_source { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_source: called CC=6 SCAR=24.3
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 522 | my ($schema, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | # Try direct match on result_class | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 522 | for my $name ($schema->sources) { | |||||||||||||||||||||||||||||||||||||||||
| 379 | 2824 | ▶ | my $src = eval { $schema->source($name) } or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 2824 | ▶ | return $src if $src->result_class eq $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | # Fallback: strip namespace prefix to guess source name | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ( $class =~ /::(?:Result::)?(\w+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | return eval { $schema->source($1) } || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
eval {
do {
$schema->source($1)
}
} || undef
MC/DC0%0/1
eval {
do {
$schema->source($1)
}
} || undef
eval {
do {
$schema->source($1)
}
}
Truth table0%0/2
A
A= eval {
do {
$schema->source($1)
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | ▶ | sub _rel_hint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_hint: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 2 | my ($rel, $op) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | ▶ | $op //= 'create'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$op //= "create"
MC/DC100%1/1
$op //= "create"
$op
Truth table100%2/2
A
A= $op
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | return "Omit '$rel' from the hashref entirely if there are no related rows to insert. " | |||||||||||||||||||||||||||||||||||||||||
| 395 | . "If you do have related rows, pass an arrayref of hashrefs: $rel => [\\%related_data]."; | ||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =head1 ADDING NEW PATTERNS | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | Add a new entry to the C<@PATTERNS> array: | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||||||||||||||||
| 403 | class => 'DBIx::Class::Async::Exception::YourSubclass', # or base class | ||||||||||||||||||||||||||||||||||||||||||
| 404 | match => qr/your regex with (\w+) captures/, | ||||||||||||||||||||||||||||||||||||||||||
| 405 | build => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | my (%p) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 407 | # $p{error} -- raw error string | ||||||||||||||||||||||||||||||||||||||||||
| 408 | # $p{captures} -- arrayref of regex captures | ||||||||||||||||||||||||||||||||||||||||||
| 409 | # $p{schema} -- schema object (may be undef) | ||||||||||||||||||||||||||||||||||||||||||
| 410 | # $p{result_class} -- e.g. 'My::Schema::Result::Foo' (may be undef) | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # $p{operation} -- e.g. 'create' (may be undef) | ||||||||||||||||||||||||||||||||||||||||||
| 412 | # | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # Return a flat %args hash to pass to the exception class constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # Return an empty list () to skip this pattern and try the next one. | ||||||||||||||||||||||||||||||||||||||||||
| 415 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 416 | message => _fmt_message("Your friendly message"), | ||||||||||||||||||||||||||||||||||||||||||
| 417 | hint => "What the user should do.", | ||||||||||||||||||||||||||||||||||||||||||
| 418 | original_error => $p{error}, | ||||||||||||||||||||||||||||||||||||||||||
| 419 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 420 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 421 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | =head1 REPOSITORY | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | L<https://github.com/manwar/DBIx-Class-Async> | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/DBIx-Class-Async/issues>. | ||||||||||||||||||||||||||||||||||||||||||
| 434 | I will be notified and then you'll automatically be notified of progress on your | ||||||||||||||||||||||||||||||||||||||||||
| 435 | bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | perldoc DBIx::Class::Async::Exception::Factory | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | =item * BUG Report | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | L<https://github.com/manwar/DBIx-Class-Async/issues> | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | L<http://cpanratings.perl.org/d/DBIx-Class-Async> | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | =item * Search MetaCPAN | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | L<https://metacpan.org/dist/DBIx-Class-Async/> | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | Copyright (C) 2026 Mohammad Sajid Anwar. | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | This program is free software; you can redistribute it and / or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 466 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||||||||||||||||||||||||||||||||||||||||||
| 467 | license at: | ||||||||||||||||||||||||||||||||||||||||||
| 468 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||||||||||||||||
| 469 | Any use, modification, and distribution of the Standard or Modified Versions is | ||||||||||||||||||||||||||||||||||||||||||
| 470 | governed by this Artistic License.By using, modifying or distributing the Package, | ||||||||||||||||||||||||||||||||||||||||||
| 471 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||||||||||||||||||||||||||||||||||||||||||
| 472 | not accept this license. | ||||||||||||||||||||||||||||||||||||||||||
| 473 | If your Modified Version has been derived from a Modified Version made by someone | ||||||||||||||||||||||||||||||||||||||||||
| 474 | other than you,you are nevertheless required to ensure that your Modified Version | ||||||||||||||||||||||||||||||||||||||||||
| 475 | complies with the requirements of this license. | ||||||||||||||||||||||||||||||||||||||||||
| 476 | This license does not grant you the right to use any trademark, service mark, | ||||||||||||||||||||||||||||||||||||||||||
| 477 | tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||||||||||||||||
| 478 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||||||||||||||||||||||||||||||||||||||||||
| 479 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||||||||||||||||||||||||||||||||||||||||||
| 480 | Package with respect to any patent claims licensable by the Copyright Holder that | ||||||||||||||||||||||||||||||||||||||||||
| 481 | are necessarily infringed by the Package. If you institute patent litigation | ||||||||||||||||||||||||||||||||||||||||||
| 482 | (including a cross-claim or counterclaim) against any party alleging that the | ||||||||||||||||||||||||||||||||||||||||||
| 483 | Package constitutes direct or contributory patent infringement,then this Artistic | ||||||||||||||||||||||||||||||||||||||||||
| 484 | License to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||||||||||||||||
| 485 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||||||||||||||||||||||||||||||||||||||||||
| 486 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||||||||||||||||||||||||||||||||||||||||||
| 487 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||||||||||||||||||||||||||||||||||||||||||
| 488 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||||||||||||||||||||||||||||||||||||||||||
| 489 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||||||||||||||||||||||||||||||||||||||||||
| 490 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||||||||||||||||||||||||||||||||||||||||||
| 491 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 102 | 1; # End of DBIx::Class::Async::Exception::Factory | |||||||||||||||||||||||||||||||||||||||||