File Coverage

blib/lib/Net/FileMaker/Error.pm
Criterion Covered Total %
statement 6 13 46.1
branch 0 2 0.0
condition 0 3 0.0
subroutine 2 3 66.6
pod 0 1 0.0
total 8 22 36.3


line stmt bran cond sub pod time code
1             package
2             Net::FileMaker::Error;
3              
4 1     1   6 use strict;
  1         2  
  1         37  
5 1     1   6 use warnings;
  1         1  
  1         156  
6              
7             =head1 NAME
8              
9             Net::FileMaker::Error - Error strings and codes
10              
11             =head1 SYNOPSIS
12              
13             Classes within this namespace store the applicable error codes, and the
14             localised strings for them. You don't call these modules yourself directly. To
15             enable them, the key "error" must be defined as an ISO 639 short code when you
16             construct your objects with L or a subclass that handles
17             individual interface types like so:
18              
19             use Net::FileMaker;
20             my $fms = Net::FileMaker->new(host => $host, error => 'en');
21              
22             =head1 LANGUAGES SUPPORTED
23              
24             English, Italian, Japanese and German are presently supported with the aims of
25             covering all languages documented by FileMaker in the future.
26              
27             =cut
28              
29             # new( lang => $lang, type => $type)
30             #
31             # Creates a new object. There is no inheritance in the Error classes, mearly
32             # factory objects. Both the language (in ISO 639) and type (XML/XSLT/IWP etc)
33             # needs be defined. Returns undef if fails to load the strings.
34             sub new
35             {
36 0     0 0   my($class, %args) = @_;
37              
38 0 0 0       if($args{lang} ne '' && $args{type} ne '')
39             {
40             #TODO: Look at Module::Load instead?
41 0           my $class = "Net/FileMaker/Error/".uc($args{lang})."/".uc($args{type}).'.pm';
42 0           my $package = "Net::FileMaker::Error::".uc($args{lang})."::".uc($args{type});
43 0           require $class;
44             #TODO: try/catch if the sub class exists?
45 0           return $package->new;
46             }
47             else
48             {
49 0           return;
50             }
51            
52             }
53              
54             1; # End of Net::FileMaker::Error