mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Move exceptions to their own file
Since that keeps the GlobalStack cleaner Contributes to CURA-3497
This commit is contained in:
parent
a95404f72f
commit
f97a6ebd74
17
cura/Settings/Exceptions.py
Normal file
17
cura/Settings/Exceptions.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Copyright (c) 2017 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
|
||||||
|
## Raised when trying to perform an operation like add on a stack that does not allow that.
|
||||||
|
class InvalidOperationError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
## Raised when trying to replace a container with a container that does not have the expected type.
|
||||||
|
class InvalidContainerError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
## Raised when trying to add an extruder to a Global stack that already has the maximum number of extruders.
|
||||||
|
class TooManyExtrudersError(Exception):
|
||||||
|
pass
|
@ -11,8 +11,7 @@ from UM.Settings.InstanceContainer import InstanceContainer
|
|||||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
from UM.Settings.DefinitionContainer import DefinitionContainer
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
|
||||||
class CannotSetNextStackError(Exception):
|
from . import Exceptions
|
||||||
pass
|
|
||||||
|
|
||||||
class GlobalStack(ContainerStack):
|
class GlobalStack(ContainerStack):
|
||||||
def __init__(self, container_id: str, *args, **kwargs):
|
def __init__(self, container_id: str, *args, **kwargs):
|
||||||
@ -78,7 +77,7 @@ class GlobalStack(ContainerStack):
|
|||||||
## Overridden from ContainerStack
|
## Overridden from ContainerStack
|
||||||
@override(ContainerStack)
|
@override(ContainerStack)
|
||||||
def setNextStack(self, next_stack: ContainerStack) -> None:
|
def setNextStack(self, next_stack: ContainerStack) -> None:
|
||||||
raise CannotSetNextStackError("Global stack cannot have a next stack!")
|
raise Exceptions.InvalidOperationError("Global stack cannot have a next stack!")
|
||||||
|
|
||||||
## Overridden from ContainerStack
|
## Overridden from ContainerStack
|
||||||
@override(ContainerStack)
|
@override(ContainerStack)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user