line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::ResultSet::Errors; |
2
|
|
|
|
|
|
|
$DBIx::Class::Helper::ResultSet::Errors::VERSION = '2.036000'; |
3
|
|
|
|
|
|
|
# ABSTRACT: add exceptions to help when calling Result methods on an ResultSets |
4
|
|
|
|
|
|
|
|
5
|
56
|
|
|
56
|
|
25427
|
use strict; |
|
56
|
|
|
|
|
122
|
|
|
56
|
|
|
|
|
1589
|
|
6
|
56
|
|
|
56
|
|
267
|
use warnings; |
|
56
|
|
|
|
|
124
|
|
|
56
|
|
|
|
|
1348
|
|
7
|
|
|
|
|
|
|
|
8
|
56
|
|
|
56
|
|
265
|
use parent 'DBIx::Class::ResultSet'; |
|
56
|
|
|
|
|
112
|
|
|
56
|
|
|
|
|
256
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $std_err = qq{Can't locate object method "%s" via package "%s" } . |
11
|
|
|
|
|
|
|
qq{at %s line %d.\n}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $cust_err = qq{You're trying to call a Result ("%s") method ("%s") } . |
14
|
|
|
|
|
|
|
qq{on a ResultSet ("%s") at %s line %d.\n}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub AUTOLOAD { |
17
|
1
|
|
|
1
|
|
628
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
33
|
|
|
7
|
my($class) = ref $self || $self; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
8
|
my($meth) = $DBIx::Class::Helper::ResultSet::Errors::AUTOLOAD |
22
|
|
|
|
|
|
|
=~ m/::([^:]+)$/; |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
5
|
return if $meth eq 'DESTROY'; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
5
|
my($callpack, $callfile, $callline) = caller; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
9
|
my $rclass = $self->result_source->result_class; |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
285
|
die sprintf $cust_err, $rclass, $meth, $class, $callfile, $callline |
31
|
|
|
|
|
|
|
if $rclass->can($meth); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
die sprintf $std_err, $meth, $class, $callfile, $callline; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
DBIx::Class::Helper::ResultSet::Errors - add exceptions to help when calling Result methods on an ResultSets |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package MyApp::Schema::ResultSet::Foo; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->load_components(qw{Helper::ResultSet::Errors}); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
... |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
And then in a script or something: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $col = $rs->id |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# dies with a helpful error! |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Users new to C<DBIx::Class> often make the mistake of treating ResultSets like |
65
|
|
|
|
|
|
|
Results. This helper ameliorates the situation by giving a helpful error when |
66
|
|
|
|
|
|
|
the user calls methods for the result on the ResultSet. See |
67
|
|
|
|
|
|
|
L<DBIx::Class::Helper::ResultSet/NOTE> for a nice way to apply it to your entire |
68
|
|
|
|
|
|
|
schema. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
79
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |