mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-09-14 17:33:20 +08:00
Exceptions are no longer general typed
CURA-1385
This commit is contained in:
parent
46ff3f4408
commit
06dfb73602
@ -3,6 +3,16 @@
|
|||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
|
|
||||||
|
## Raised when trying to add an unknown machine action as a required action
|
||||||
|
class UnknownMachineAction(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
## Raised when trying to add a machine action that does not have an unique key.
|
||||||
|
class NotUniqueMachineAction(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MachineActionManager:
|
class MachineActionManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
## Dict of all known machine actions
|
## Dict of all known machine actions
|
||||||
@ -26,8 +36,7 @@ class MachineActionManager:
|
|||||||
else:
|
else:
|
||||||
self._required_actions[machine] = set(self._machine_actions[action_key])
|
self._required_actions[machine] = set(self._machine_actions[action_key])
|
||||||
else:
|
else:
|
||||||
# Todo: define specific Exception types (instead of general type)
|
raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine.getKey()))
|
||||||
raise Exception("Action %s, which is required for %s is not known." % (action_key, machine.getKey()))
|
|
||||||
|
|
||||||
## Add a supported action to a machine.
|
## Add a supported action to a machine.
|
||||||
def addSupportedAction(self, machine, action_key):
|
def addSupportedAction(self, machine, action_key):
|
||||||
@ -55,8 +64,7 @@ class MachineActionManager:
|
|||||||
if action.getKey() not in self._machine_action:
|
if action.getKey() not in self._machine_action:
|
||||||
self._machine_action[action.getKey()] = action
|
self._machine_action[action.getKey()] = action
|
||||||
else:
|
else:
|
||||||
# Todo: define specific Exception types (instead of general type)
|
raise NotUniqueMachineAction("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey())
|
||||||
raise Exception("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey())
|
|
||||||
|
|
||||||
## Get all actions supported by given machine
|
## Get all actions supported by given machine
|
||||||
# \param machine The machine you want the supported actions of
|
# \param machine The machine you want the supported actions of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user