source: CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch/pyoasis/src/abort.py @ 6331

Last change on this file since 6331 was 6331, checked in by aclsce, 17 months ago

Moved oasis-mct_5.0 in oasis3-mct/branches directory.

File size: 2.5 KB
Line 
1# pyOASIS - A Python wrapper for OASIS
2# Authors: Philippe Gambron, Rupert Ford
3# Copyright (C) 2019 UKRI - STFC
4
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation, either version 3 of the
8# License, or any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details.
14
15# A copy of the GNU Lesser General Public License, version 3, is supplied
16# with this program, in the file lgpl-3.0.txt. It is also available at
17# <https://www.gnu.org/licenses/lgpl-3.0.html>.
18
19
20import pyoasis.exception
21
22import pyoasis.mod_oasis_method
23import pyoasis.mod_oasis_auxiliary_routines
24import pyoasis.mod_oasis_sys
25import pyoasis.mod_oasis_part
26import pyoasis.mod_oasis_var
27import pyoasis.mod_oasis_getput_interface
28
29import traceback
30
31
32# oasis_abort instead of simply abort because there
33# was a clash with another function name
34def oasis_abort(component_id, routine, message, filename, line, error):
35    """   
36    Stops the execution of all the processes corresponding to the components
37    after having displayed an error message and written to the log
38    files information about the error and the context in which it
39    took place.
40   
41    :param int component_id: Identifier of the component
42    :param str routine: Name of the routine
43    :param str message: Error message
44    :param int line: Line
45    :param int error: Error code
46    """
47    pyoasis.check_types([int, str, str, str, int, int],
48                        [component_id, routine, message, filename, line,
49                        error])
50    pyoasis.mod_oasis_sys.oasis_abort(component_id, routine, message, filename,
51                                      line, error)
52
53
54def pyoasis_abort(exception):
55    """   
56    Stops the execution of all the processes corresponding to the components
57    after having displayed an error message and written to the log
58    files information about the error and the context in which it
59    took place.
60   
61    :param Exception exception: exception to be handled
62    :raises PyOasisException: if the argument is not an exception
63    """
64    pyoasis.check_types([Exception], [exception])
65    print(traceback.format_exc())
66    pyoasis.mod_oasis_sys.oasis_abort(0, "", str(exception), "", 0, 0)
Note: See TracBrowser for help on using the repository browser.