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:
Gina Häußge committed 2015-06-28 02:19:28 +02:00
1 parent 1796c92913
commit 29b047bf09
5 files changed
+11 -11

No files matched your search

+4 -4
View File
@@ -1213,15 +1213,15 @@ class Plugin(object):
class RestartNeedingPlugin(Plugin):
pass
class PluginNeedsRestart(BaseException):
class PluginNeedsRestart(Exception):
def __init__(self, name):
BaseException.__init__(self)
Exception.__init__(self)
self.name = name
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):
BaseException.__init__(self)
Exception.__init__(self)
self.name = name
self.reason = reason
+1 -1
View File
@@ -467,6 +467,6 @@ class PrinterCallback(object):
"""
pass
class UnknownScript(BaseException):
class UnknownScript(Exception):
def __init__(self, name, *args, **kwargs):
self.name = name
+1 -1
View File
@@ -143,5 +143,5 @@ def _validate_archive_name(name):
raise InvalidLanguagePack("Provided language pack contains invalid name {name}".format(**locals()))
class InvalidLanguagePack(BaseException):
class InvalidLanguagePack(Exception):
pass
+3 -3
View File
@@ -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"
class SlicingException(BaseException):
class SlicingException(Exception):
"""
Base exception of all slicing related exceptions.
"""
@@ -73,7 +73,7 @@ class UnknownSlicer(SlicerException):
SlicerException.__init__(self, slicer, *args, **kwargs)
self.message = "No such slicer: {slicer}".format(slicer=slicer)
class ProfileException(BaseException):
class ProfileException(Exception):
"""
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.
"""
def __init__(self, slicer, profile, *args, **kwargs):
BaseException.__init__(self, *args, **kwargs)
Exception.__init__(self, *args, **kwargs)
self.slicer = slicer
self.profile = profile
+2 -2
View File
@@ -1982,9 +1982,9 @@ class TypedQueue(queue.Queue):
return item
class TypeAlreadyInQueue(BaseException):
class TypeAlreadyInQueue(Exception):
def __init__(self, t, *args, **kwargs):
BaseException.__init__(self, *args, **kwargs)
Exception.__init__(self, *args, **kwargs)
self.type = t