ars / ars / exceptions.py

"""ARS's exceptions class hierarchy.

"""

###############################################################################
# doc/python2.7/html/tutorial/errors.html#tut-userexceptions
# "When creating a module that can raise several distinct errors, a common
# practice is to create a base class for exceptions defined by that module, and
# subclass it to create specific exception classes for different error
# conditions."
###############################################################################


class ArsError(Exception):

	"""Base class for exceptions in this library.

	Attributes:
		msg  -- explanation of the error

	"""

	def __init__(self, msg=None):
		super(ArsError, self).__init__()
		self.msg = msg


class PhysicsEngineException(ArsError):

	"""Exception raised for errors in a physics engine.

	Attributes:
		msg  -- explanation of the error

	"""

	pass


class JointError(PhysicsEngineException):

	"""Exception raised for errors related to physical joints.

	Attributes:
		joint	-- joint in which the error occurred
		msg		-- explanation of the error

	"""

	def __init__(self, joint, msg=None):
		super(JointError, self).__init__(msg)
		self.joint = joint


class PhysicsObjectCreationError(PhysicsEngineException):

	"""Exception raised for errors in physics-engine objects creation.

	Attributes:
		type	-- type of the object being created
		msg		-- explanation of the error

	"""

	def __init__(self, type, msg=None):
		super(PhysicsObjectCreationError, self).__init__(msg)
		self.type = type
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.