]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/perlmods/OpenSRF.pm
18d157a0cf91edcf5ab2e351f419340fc667f82f
[OpenSRF.git] / src / perlmods / OpenSRF.pm
1 package OpenILS;
2 use strict;
3 use Error;
4 use vars qw/$VERSION $AUTOLOAD/;
5 $VERSION = do { my @r=(q$Revision$=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
6
7 =head1 OpenILS
8
9 =cut
10
11 =head2 Overview
12
13  Top level class for OpenILS perl modules.
14
15 =cut
16
17 # Exception base classes
18 #use Exception::Class
19 #       ( OpenILSException => { fields => [ 'errno' ] });
20 #push @Exception::Class::ISA, 'Error';
21
22 =head3 AUTOLOAD()
23
24  Traps methods calls for methods that have not been defined so they
25  don't propogate up the class hierarchy.
26
27 =cut
28 sub AUTOLOAD {
29         my $self = shift;
30         my $type = ref($self) || $self;
31         my $name = $AUTOLOAD;
32         my $otype = ref $self;
33         
34         my ($package, $filename, $line) = caller;
35         my ($package1, $filename1, $line1) = caller(1);
36         my ($package2, $filename2, $line2) = caller(2);
37         my ($package3, $filename3, $line3) = caller(3);
38         my ($package4, $filename4, $line4) = caller(4);
39         my ($package5, $filename5, $line5) = caller(5);
40         $name =~ s/.*://;   # strip fully-qualified portion
41         warn <<"        WARN";
42 ****
43 ** ${name}() isn't there.  Please create me somewhere (like in $type)!
44 ** Error at $package ($filename), line $line
45 ** Call Stack (5 deep):
46 **      $package1 ($filename1), line $line1
47 **      $package2 ($filename2), line $line2
48 **      $package3 ($filename3), line $line3
49 **      $package4 ($filename4), line $line4
50 **      $package5 ($filename5), line $line5
51 ** Object type was $otype
52 ****
53         WARN
54 }
55
56
57
58 =head3 alert_abstract()
59
60  This method is called by abstract methods to ensure that
61  the process dies when an undefined abstract method is called
62
63 =cut
64 sub alert_abstract() {
65         my $c = shift;
66         my $class = ref( $c ) || $c;
67         my ($file, $line, $method) = (caller(1))[1..3];
68         die " * Call to abstract method $method at $file, line $line";
69 }
70
71 sub class {
72         return scalar(caller);
73 }
74
75 1;