daemon: moved service boot error to core.errors with all other core specific errors

This commit is contained in:
Blake Harnden 2020-08-27 10:46:55 -07:00
parent 5300eef27e
commit f6992e7545
2 changed files with 18 additions and 9 deletions

View file

@ -38,3 +38,11 @@ class CoreServiceError(Exception):
"""
pass
class CoreServiceBootError(Exception):
"""
Used when there is an error booting a service.
"""
pass

View file

@ -25,7 +25,12 @@ from typing import (
from core import utils
from core.emulator.data import FileData
from core.emulator.enumerations import ExceptionLevels, MessageFlags, RegisterTlvs
from core.errors import CoreCommandError, CoreError, CoreServiceError
from core.errors import (
CoreCommandError,
CoreError,
CoreServiceBootError,
CoreServiceError,
)
from core.nodes.base import CoreNode
if TYPE_CHECKING:
@ -34,10 +39,6 @@ if TYPE_CHECKING:
CoreServiceType = Union["CoreService", Type["CoreService"]]
class ServiceBootError(Exception):
pass
class ServiceMode(enum.Enum):
BLOCKING = 0
NON_BLOCKING = 1
@ -453,7 +454,7 @@ class CoreServices:
funcs.append((self._boot_service_path, args, {}))
result, exceptions = utils.threadpool(funcs)
if exceptions:
raise ServiceBootError(*exceptions)
raise CoreServiceBootError(*exceptions)
def _boot_service_path(self, node: CoreNode, boot_path: List["CoreServiceType"]):
logging.info(
@ -467,7 +468,7 @@ class CoreServices:
self.boot_service(node, service)
except Exception as e:
logging.exception("exception booting service: %s", service.name)
raise ServiceBootError(e)
raise CoreServiceBootError(e)
def boot_service(self, node: CoreNode, service: "CoreServiceType") -> None:
"""
@ -504,7 +505,7 @@ class CoreServices:
wait = service.validation_mode == ServiceMode.BLOCKING
status = self.startup_service(node, service, wait)
if status:
raise ServiceBootError(
raise CoreServiceBootError(
"node(%s) service(%s) error during startup" % (node.name, service.name)
)
@ -529,7 +530,7 @@ class CoreServices:
time.sleep(service.validation_period)
if status:
raise ServiceBootError(
raise CoreServiceBootError(
"node(%s) service(%s) failed validation" % (node.name, service.name)
)