aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-29 18:27:48 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-29 18:49:12 -0500
commitf547cab7109635e663585a0704eb3b06f194a2d0 (patch)
tree851694e00ac9237d0f74069cef8024ab7697b7ef
parent7835f50722ac511b5696de2df4e6e1ab2ef26731 (diff)
downloadkutter-f547cab7109635e663585a0704eb3b06f194a2d0.tar.gz
kutter-f547cab7109635e663585a0704eb3b06f194a2d0.tar.xz
kutter-f547cab7109635e663585a0704eb3b06f194a2d0.zip
klippy: No need to define __str__ and __init__ methods on exception classes
The base Exception class already defines these methods. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/homing.py9
-rw-r--r--klippy/mcu.py11
-rw-r--r--klippy/msgproto.py5
3 files changed, 8 insertions, 17 deletions
diff --git a/klippy/homing.py b/klippy/homing.py
index 4d5ab505..384da3dd 100644
--- a/klippy/homing.py
+++ b/klippy/homing.py
@@ -78,7 +78,7 @@ class Homing:
try:
if es.check_busy(self.eventtime):
return True
- except mcu.MCUError, e:
+ except mcu.error, e:
raise EndstopError("Failed to home stepper %s: %s" % (
stepper.name, str(e)))
post_home_pos = stepper.mcu_stepper.get_mcu_position()
@@ -110,7 +110,7 @@ class QueryEndstops:
try:
if self.busy[0][1].check_busy(eventtime):
return True
- except mcu.MCUError, e:
+ except mcu.error, e:
raise EndstopError("Failed to query endstop %s: %s" % (
self.busy[0][0], str(e)))
self.busy.pop(0)
@@ -125,10 +125,7 @@ class QueryEndstops:
return False
class EndstopError(Exception):
- def __init__(self, msg="Endstop error"):
- self._msg = msg
- def __str__(self):
- return self._msg
+ pass
def EndstopMoveError(pos, msg="Move out of range"):
return EndstopError("%s: %.3f %.3f %.3f [%.3f]" % (
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 200c6256..1c309f6c 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -6,11 +6,8 @@
import sys, zlib, logging, time, math
import serialhdl, pins, chelper
-class MCUError(Exception):
- def __init__(self, msg="MCU Error"):
- self._msg = msg
- def __str__(self):
- return self._msg
+class error(Exception):
+ pass
def parse_pin_extras(pin, can_pullup=False):
pullup = invert = 0
@@ -167,9 +164,9 @@ class MCU_endstop:
# Timeout - disable endstop checking
msg = self._home_cmd.encode(self._oid, 0, 0, 0)
self._mcu.send(msg, reqclock=0, cq=self._cmd_queue)
- raise MCUError("Timeout during endstop homing")
+ raise error("Timeout during endstop homing")
if self._mcu.is_shutdown:
- raise MCUError("MCU is shutdown")
+ raise error("MCU is shutdown")
last_clock = self._mcu.get_last_clock()
if last_clock >= self._next_query_clock:
self._next_query_clock = last_clock + self._retry_query_ticks
diff --git a/klippy/msgproto.py b/klippy/msgproto.py
index 73c8d2d5..76dc0544 100644
--- a/klippy/msgproto.py
+++ b/klippy/msgproto.py
@@ -24,10 +24,7 @@ MESSAGE_DEST = 0x10
MESSAGE_SYNC = '\x7E'
class error(Exception):
- def __init__(self, msg):
- self.msg = msg
- def __str__(self):
- return self.msg
+ pass
def crc16_ccitt(buf):
crc = 0xffff