1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24package pre2par::exiter;
25
26use pre2par::files;
27use pre2par::globals;
28
29############################################
30# Exiting the program with an error
31# This function is used instead of "die"
32############################################
33
34sub exit_program
35{
36	my ($message, $function) = @_;
37
38	my $infoline;
39
40	$infoline = "\n***************************************************************\n";
41	push(@pre2par::globals::logfileinfo, $infoline);
42	print("$infoline");
43
44	$infoline = "$message\n";
45	push(@pre2par::globals::logfileinfo, $infoline);
46	print("$infoline");
47
48	$infoline = "in function: $function\n";
49	push(@pre2par::globals::logfileinfo, $infoline);
50	print("$infoline");
51
52	$infoline = "***************************************************************\n";
53	push(@pre2par::globals::logfileinfo, $infoline);
54
55	if ($pre2par::globals::logging)
56	{
57		pre2par::files::save_file($pre2par::globals::logfilename ,\@pre2par::globals::logfileinfo);
58		print("Saved logfile: $pre2par::globals::logfilename\n");
59	}
60
61	print("$infoline");
62
63	exit(-1);
64}
65
661;
67