1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Merge pull request #100 from altlinux/exception_handling

util.exceptions.geterr() - function to fetch erxception information
This commit is contained in:
NIR 2020-07-24 14:01:32 +04:00 committed by GitHub
commit efa5573d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

41
gpoa/util/exceptions.py Normal file
View File

@ -0,0 +1,41 @@
#
# GPOA - GPO Applier for Linux
#
# Copyright (C) 2019-2020 BaseALT Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
def geterr():
'''
Fetches information about recent exception so we will be able
to print tracebacks and other information in a uniform way.
'''
etype, evalue, etrace = sys.exc_info()
traceinfo = dict({
'file': etrace.tb_frame.f_code.co_filename
, 'line': etrace.tb_lineno
, 'name': etrace.tb_frame.f_code.co_name
, 'type': etype.__name__
, 'message': evalue.message
})
del(etype, evalue, etrace)
return traceinfo