Fix: Use Exception, not BaseException
Custom exception should be derived from Exception, not BaseException. Not only is this specified in the python documentation, but also tornado will be able to handle Exceptions in requests perfectly fine and return an HTTP 500 for them, but crash hard (as in, server shut down follows) for BaseExceptions.
This commit is contained in:
parent
1796c92913
commit
29b047bf09
5 changed files with 11 additions and 11 deletions
|
|
@ -1213,15 +1213,15 @@ class Plugin(object):
|
||||||
class RestartNeedingPlugin(Plugin):
|
class RestartNeedingPlugin(Plugin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class PluginNeedsRestart(BaseException):
|
class PluginNeedsRestart(Exception):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
BaseException.__init__(self)
|
Exception.__init__(self)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.message = "Plugin {name} cannot be enabled or disabled after system startup".format(**locals())
|
self.message = "Plugin {name} cannot be enabled or disabled after system startup".format(**locals())
|
||||||
|
|
||||||
class PluginLifecycleException(BaseException):
|
class PluginLifecycleException(Exception):
|
||||||
def __init__(self, name, reason, message):
|
def __init__(self, name, reason, message):
|
||||||
BaseException.__init__(self)
|
Exception.__init__(self)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.reason = reason
|
self.reason = reason
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,6 @@ class PrinterCallback(object):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class UnknownScript(BaseException):
|
class UnknownScript(Exception):
|
||||||
def __init__(self, name, *args, **kwargs):
|
def __init__(self, name, *args, **kwargs):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
|
||||||
|
|
@ -143,5 +143,5 @@ def _validate_archive_name(name):
|
||||||
raise InvalidLanguagePack("Provided language pack contains invalid name {name}".format(**locals()))
|
raise InvalidLanguagePack("Provided language pack contains invalid name {name}".format(**locals()))
|
||||||
|
|
||||||
|
|
||||||
class InvalidLanguagePack(BaseException):
|
class InvalidLanguagePack(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agp
|
||||||
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
class SlicingException(BaseException):
|
class SlicingException(Exception):
|
||||||
"""
|
"""
|
||||||
Base exception of all slicing related exceptions.
|
Base exception of all slicing related exceptions.
|
||||||
"""
|
"""
|
||||||
|
|
@ -73,7 +73,7 @@ class UnknownSlicer(SlicerException):
|
||||||
SlicerException.__init__(self, slicer, *args, **kwargs)
|
SlicerException.__init__(self, slicer, *args, **kwargs)
|
||||||
self.message = "No such slicer: {slicer}".format(slicer=slicer)
|
self.message = "No such slicer: {slicer}".format(slicer=slicer)
|
||||||
|
|
||||||
class ProfileException(BaseException):
|
class ProfileException(Exception):
|
||||||
"""
|
"""
|
||||||
Base exception of all slicing profile related exceptions.
|
Base exception of all slicing profile related exceptions.
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ class ProfileException(BaseException):
|
||||||
Identifier of the profile for which the exception was raised.
|
Identifier of the profile for which the exception was raised.
|
||||||
"""
|
"""
|
||||||
def __init__(self, slicer, profile, *args, **kwargs):
|
def __init__(self, slicer, profile, *args, **kwargs):
|
||||||
BaseException.__init__(self, *args, **kwargs)
|
Exception.__init__(self, *args, **kwargs)
|
||||||
self.slicer = slicer
|
self.slicer = slicer
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1982,9 +1982,9 @@ class TypedQueue(queue.Queue):
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
class TypeAlreadyInQueue(BaseException):
|
class TypeAlreadyInQueue(Exception):
|
||||||
def __init__(self, t, *args, **kwargs):
|
def __init__(self, t, *args, **kwargs):
|
||||||
BaseException.__init__(self, *args, **kwargs)
|
Exception.__init__(self, *args, **kwargs)
|
||||||
self.type = t
|
self.type = t
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue