logger handles exception
This commit is contained in:
@@ -33,4 +33,7 @@ logger.info(f"{v1=}")
|
|||||||
logger.info(f"{v2=}")
|
logger.info(f"{v2=}")
|
||||||
logger.info(f"{v3=}")
|
logger.info(f"{v3=}")
|
||||||
|
|
||||||
v4 = v2.dot([1,2,3])
|
try:
|
||||||
|
v4 = v2.dot([1,2,3])
|
||||||
|
except ValueError as err:
|
||||||
|
logger.exception(err)
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class Vector(object):
|
|||||||
def dot(self, v):
|
def dot(self, v):
|
||||||
"""Returns the dot product with Vector *v*."""
|
"""Returns the dot product with Vector *v*."""
|
||||||
if not isinstance(v, self.__class__):
|
if not isinstance(v, self.__class__):
|
||||||
logger.error(f"Expected an instance of {self.__class__}, but got {type(v)} instead.")
|
msg = f"Expected an instance of {self.__class__}, but got {type(v)} instead."
|
||||||
return None
|
raise ValueError(msg)
|
||||||
d = self.x * v.x + self.y * v.y + self.z * v.z
|
d = self.x * v.x + self.y * v.y + self.z * v.z
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user