homing: Add EndstopMoveError wrapper around EndstopError

Allow an EndstopError to be raised without a destination position.
Introduce EndstopMoveError wrapper so that current callers can
continue to pass in a move destination.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-11-18 12:42:39 -05:00
parent 2b5b899d35
commit 4f30dce64f
4 changed files with 15 additions and 11 deletions

View file

@ -104,9 +104,11 @@ class QueryEndstops:
return False
class EndstopError(Exception):
def __init__(self, pos, msg="Move out of range"):
self.pos = pos
self.msg = msg
def __init__(self, msg="Endstop error"):
self._msg = msg
def __str__(self):
return "%s: %.3f %.3f %.3f [%.3f]" % (
self.msg, self.pos[0], self.pos[1], self.pos[2], self.pos[3])
return self._msg
def EndstopMoveError(pos, msg="Move out of range"):
return EndstopError("%s: %.3f %.3f %.3f [%.3f]" % (
msg, pos[0], pos[1], pos[2], pos[3]))