Editor:Proposal:Exception handling

From FIFE development wiki
(Redirected from Editor:Proposals)
Jump to: navigation, search

This article is currently only a proposal

The features or design guidelines described in this article are only a proposal made by one or some persons. It has not been reviewed and ratified by the core development team yet. Feel free to add your personal opinion about them or make counter proposals.

User friendly exception handling

The current exception handling of the editor core is (sometimes) too strict. IMO it doesn't make sense to let the editor throw exceptions if e.g. no layer is selected - a better reaction would be to not perform layer actions in this case. (and give a hint to the user to select a layer first)

Example

Python:

def _getInstancesFromPosition(self, position, top_only):
self._assert(self._layer, 'No layer assigned in _getInstancesFromPosition')
self._assert(position, 'No position assigned in _getInstancesFromPosition')
self._assert(self._camera, 'No camera assigned in _getInstancesFromPosition')
# [..]

A proposal to alter this example code would be:

Python:

def _getInstanceFromPosition(self, position, top_only):
if self._layer is None: return
if position is None: return
if self._camera is None: return
# [..]
Personal tools