Debian Codegraph @

solenv/bin/modules/par2script/exiter.pm

raw
1 #
2 # This file is part of the LibreOffice project.
3 #
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 #
8 # This file incorporates work covered by the following license notice:
9 #
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 #
18
19
20 package par2script::exiter;
21
22 use par2script::files;
23 use par2script::globals;
24
25 ############################################
26 # Exiting the program with an error
27 # This function is used instead of "die"
28 ############################################
29
30 sub exit_program
31 {
32 my ($message, $function) = @_;
33
34 my $infoline;
35
36 $infoline = "\n***************************************************************\n";
37 push(@par2script::globals::logfileinfo, $infoline);
38 print("$infoline");
39
40 $infoline = "$message\n";
41 push(@par2script::globals::logfileinfo, $infoline);
42 print("$infoline");
43
44 $infoline = "in function: $function\n";
45 push(@par2script::globals::logfileinfo, $infoline);
46 print("$infoline");
47
48 $infoline = "***************************************************************\n";
49 push(@par2script::globals::logfileinfo, $infoline);
50
51 if ($par2script::globals::logging)
52 {
53 par2script::files::save_file($par2script::globals::logfilename, \@par2script::globals::logfileinfo);
54 print("Saved logfile: $par2script::globals::logfilename\n");
55 }
56
57 print("$infoline");
58
59 exit(-1);
60 }
61
62 #####################################
63 # Error, because a gid is defined
64 # more than once
65 #####################################
66
67 sub multidefinitionerror
68 {
69 my ( $multidefinitiongids ) = @_;
70 print "************************************************\n";
71 print "ERROR: multiple definition of gids:\n";
72 print "************************************************\n";
73
74 my $gid;
75 foreach $gid ( @{$multidefinitiongids} ) { print "\t$gid\n"; }
76 exit(-1);
77 }
78
79 #####################################
80 # Error, because a gid is assigned
81 # more than once
82 #####################################
83
84 sub multiassignmenterror
85 {
86 my ( $multiassignmentgids ) = @_;
87 print "************************************************\n";
88 print "WARNING: multiple assignments of gids:\n";
89 print "************************************************\n";
90
91 my $line;
92 foreach $line ( @{$multiassignmentgids} ) { print "\t$line\n"; }
93 }
94
95 #####################################
96 # Error, because a defined gid
97 # is not assigned
98 #####################################
99
100 sub missingassignmenterror
101 {
102 my ( $missingassignmentgids ) = @_;
103 print "********************************************************\n";
104 print "ERROR: Missing assignments for the following GIDs:\n";
105 print "********************************************************\n";
106
107 my $gid;
108 foreach $gid ( @{$missingassignmentgids} ) { print "\t$gid\n"; }
109 exit(-1);
110 }
111
112 1;