source: LMDZ6/branches/Amaury_dev/tools/fcm/lib/FCM/Util/Exception.pm

Last change on this file was 5129, checked in by abarral, 4 months ago

Re-add removed by mistake fcm

File size: 7.7 KB
Line 
1# ------------------------------------------------------------------------------
2# Copyright (C) 2006-2021 British Crown (Met Office) & Contributors.
3#
4# This file is part of FCM, tools for managing and building source code.
5#
6# FCM is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# FCM is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with FCM. If not, see <http://www.gnu.org/licenses/>.
18# ------------------------------------------------------------------------------
19use strict;
20use warnings;
21# ------------------------------------------------------------------------------
22
23package FCM::Util::Exception;
24use base qw{FCM::Exception};
25
26use constant {
27    CLASS_LOADER         => 'CLASS_LOADER',
28    CONFIG_CONT_EOF      => 'CONFIG_CONT_EOF',
29    CONFIG_CYCLIC        => 'CONFIG_CYCLIC',
30    CONFIG_LOAD          => 'CONFIG_LOAD',
31    CONFIG_SYNTAX        => 'CONFIG_SYNTAX',
32    CONFIG_USAGE         => 'CONFIG_USAGE',
33    CONFIG_VAR_UNDEF     => 'CONFIG_VAR_UNDEF',
34    IO                   => 'IO',
35    LOCATOR_AS_INVARIANT => 'LOCATOR_AS_INVARIANT',
36    LOCATOR_BROWSER_URL  => 'LOCATOR_BROWSER_URL',
37    LOCATOR_FIND         => 'LOCATOR_FIND',
38    LOCATOR_KEYWORD_LOC  => 'LOCATOR_KEYWORD_LOC',
39    LOCATOR_KEYWORD_REV  => 'LOCATOR_KEYWORD_REV',
40    LOCATOR_READER       => 'LOCATOR_READER',
41    LOCATOR_TYPE         => 'LOCATOR_TYPE',
42    SHELL_OPEN3          => 'SHELL_OPEN3',
43    SHELL_OS             => 'SHELL_OS',
44    SHELL_SIGNAL         => 'SHELL_SIGNAL',
45    SHELL_WHICH          => 'SHELL_WHICH',
46};
47
48# ------------------------------------------------------------------------------
491;
50__END__
51
52=head1 NAME
53
54FCM::Util::Exception
55
56=head1 SYNOPSIS
57
58    use FCM::Util::Exception;
59    eval {
60        # something does not work ...
61        FCM::Util::Exception->throw($code, $ctx, $exception);
62    };
63    if (my $e = $@) {
64        if (FCM::Util::Exception->caught($e)) {
65            # do something ...
66        }
67        else {
68            # do something else ...
69        }
70    }
71
72=head1 DESCRIPTION
73
74This exception represents an error condition in an FCM utility. It is a
75sub-class of L<FCM::Exception|FCM::Exception>.
76
77=head1 CONSTANTS
78
79The following are known error code:
80
81=over 4
82
83=item CLASS_LOADER
84
85L<FCM::Util::ClassLoader|FCM::Util::ClassLoader>: The utility fails to load the
86specified class. The $e->get_ctx() method returns the name of the class it fails
87to load.
88
89=item CONFIG_CONT_EOF
90
91L<FCM::Util::ConfigReader|FCM::Util::ConfigReader>: The last line of the
92configuration file has a continuation marker. Expects the $e->get_ctx() method
93to return the L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry> object that
94represents the problem entry.
95
96=item CONFIG_CYCLIC
97
98L<FCM::Util::ConfigReader|FCM::Util::ConfigReader>: There is a cyclic dependency
99in the include hierarchy. Expects the $e->get_ctx() method to return an ARRAY
100reference of the locator stack. (The last element of the ARRAY is the top of the
101stack, and each element is a 2-element ARRAY reference, where the first element
102is a L<FCM::Context::Locator|FCM::Context::Locator> object and the second
103element is the line number.)
104
105=item CONFIG_LOAD
106
107L<FCM::Util::ConfigReader|FCM::Util::ConfigReader>: An error occurs when loading
108a configuration file. Expects the $e->get_ctx() method to return an ARRAY
109reference of the locator stack. (The last element of the ARRAY is the top of the
110stack, and each element is a 2-element ARRAY reference, where the first element
111is a L<FCM::Context::Locator|FCM::Context::Locator> object and the second
112element is the line number.)
113
114=item CONFIG_SYNTAX
115
116L<FCM::Util::ConfigReader|FCM::Util::ConfigReader>: A syntax error in the
117declaration. Expects the $e->get_ctx() method to return the
118L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry> object that represents
119the problem entry.
120
121=item CONFIG_USAGE
122
123L<FCM::Util::ConfigReader|FCM::Util::ConfigReader>: An attempt to assign a value
124to a reserved variable. Expects the $e->get_ctx() method to return the
125L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry> object that represents
126the problem entry.
127
128=item CONFIG_VAR_UNDEF
129
130L<FCM::Util::ConfigReader|FCM::Util::ConfigReader>: References to an undefined
131variable. Expects the $e->get_ctx() method to return the
132L<FCM::Context::ConfigEntry|FCM::Context::ConfigEntry> object that represents
133the problem entry, and $e->get_exception() to return a string that looks like
134"undef($symbol)" where $symbol is the symbol that references the variable.
135
136=item IO
137
138L<FCM::Util::IO|FCM::Util::IO>: I/O exception. Expects $e->get_ctx() to return
139the path that triggers the exception, and the $e->get_exception() to return the
140$! string.
141
142=item LOCATOR_AS_INVARIANT
143
144L<FCM::Util::Locator|FCM::Util::Locator>: The invariant value of the locator
145cannot be determined. Expects $e->get_ctx() method to return the associated
146L<FCM::Context::Locator|FCM::Context::Locator> object.
147
148=item LOCATOR_BROWSER_URL
149
150L<FCM::Util::Locator|FCM::Util::Locator>: The locator cannot be mapped to a
151browser URL. Expects $e->get_ctx() method to return the associated
152L<FCM::Context::Locator|FCM::Context::Locator> object.
153
154=item LOCATOR_FIND
155
156L<FCM::Util::Locator|FCM::Util::Locator>: The locator does not exist. Expects
157$e->get_ctx() method to return the associated
158L<FCM::Context::Locator|FCM::Context::Locator> object.
159
160=item LOCATOR_KEYWORD_LOC
161
162L<FCM::Util::Locator|FCM::Util::Locator>: The location keyword as specified in
163the locator is not defined. Expects $e->get_ctx() method to return the
164associated L<FCM::Context::Locator|FCM::Context::Locator> object.
165
166=item LOCATOR_KEYWORD_REV
167
168L<FCM::Util::Locator|FCM::Util::Locator>: The revision keyword as specified in
169the locator is not defined. Expects $e->get_ctx() method to return the
170associated L<FCM::Context::Locator|FCM::Context::Locator> object.
171
172=item LOCATOR_READER
173
174L<FCM::Util::Locator|FCM::Util::Locator>: The locator cannot be read. Expects
175$e->get_ctx() method to return the associated
176L<FCM::Context::Locator|FCM::Context::Locator> object.
177
178=item LOCATOR_TYPE
179
180L<FCM::Util::Locator|FCM::Util::Locator>: The locator type cannot be determined
181or cannot be supported. Expects $e->get_ctx() method to return the associated
182L<FCM::Context::Locator|FCM::Context::Locator> object.
183
184=item LOCATOR_WHEN
185
186L<FCM::Util::Locator|FCM::Util::Locator>: The last modified date and revision of
187the locator cannot be determined. Expects $e->get_ctx() method to return the
188associated L<FCM::Context::Locator|FCM::Context::Locator> object.
189
190=item SHELL_OPEN3
191
192L<FCM::Util::Shell|FCM::Util::Shell>: The utility fails to invoke
193IPC::Open3::open3(). Expects $e->get_ctx() to return an ARRAY reference of the
194command line, and $e->get_exception() to return the error from open3().
195
196=item SHELL_OS
197
198L<FCM::Util::Shell|FCM::Util::Shell>: An OS error occurs when invoking a shell
199command. Expects $e->get_ctx() to return an ARRAY reference of the
200command line, and $e->get_exception() to return $!.
201
202=item SHELL_SIGNAL
203
204L<FCM::Util::Shell|FCM::Util::Shell>: The system receives a signal when invoking
205a shell command. Expects $e->get_ctx() to return an ARRAY reference of the
206command line, and $e->get_exception() to return the signal number.
207
208=item SHELL_WHICH
209
210L<FCM::Util::Shell|FCM::Util::Shell>: The shell command does not exist in the
211PATH. Expects $e->get_ctx() to return an ARRAY reference of the command line.
212
213=back
214
215=head1 COPYRIGHT
216
217Copyright (C) 2006-2021 British Crown (Met Office) & Contributors.
218
219=cut
Note: See TracBrowser for help on using the repository browser.