| 1 |
# The main author of Bacula(R) - The Network Backup Solution |
| 2 |
# |
| 3 |
# Copyright (C) 2000-2022 Kern Sibbald |
| 4 |
# |
| 5 |
# The original author of Bacula is Kern Sibbald, with contributions |
| 6 |
# from many others, a complete list can be found in the file AUTHORS. |
| 7 |
# |
| 8 |
# You may use this file and others of this release according to the |
| 9 |
# license defined in the LICENSE file, which includes the Affero General |
| 10 |
# Public License, v3.0 ("AGPLv3") and some additional permissions and |
| 11 |
# terms pursuant to its AGPLv3 Section 7. |
| 12 |
# |
| 13 |
# This notice must be preserved when any source code is |
| 14 |
# conveyed and/or propagated. |
| 15 |
# |
| 16 |
# Bacula(R) is a registered trademark of Kern Sibbald. |
| 17 |
import logging |
| 18 |
import traceback |
| 19 |
|
| 20 |
from baculak8s.io.default_io import DefaultIO |
| 21 |
from baculak8s.io.packet_definitions import UNEXPECTED_ERROR_PACKET |
| 22 |
from baculak8s.services.service import Service |
| 23 |
|
| 24 |
|
| 25 |
class UnexpectedErrorService(Service): |
| 26 |
""" |
| 27 |
Service that is executed whenever an unexpected exception happens |
| 28 |
during the Backend execution. |
| 29 |
""" |
| 30 |
|
| 31 |
def __init__(self): |
| 32 |
self.io = DefaultIO() |
| 33 |
|
| 34 |
def execute(self, params=None): |
| 35 |
# We log the Exception Stack Trace |
| 36 |
logging.error(UNEXPECTED_ERROR_PACKET) |
| 37 |
logging.error(traceback.format_exc()) |
| 38 |
self.io.send_abort(UNEXPECTED_ERROR_PACKET) |