Opened 7 years ago

Closed 5 years ago

#25 closed defect (fixed)

Raise exceptions in exporters instead of returning errors

Reported by: olivier Owned by: yomguy
Priority: major Milestone: 0.4
Component: Export Version:
Keywords: Cc:

Description

In many places, you return or yield error strings from the exporters methods. These errors can't be properly caught by the Python error handling mechanism, and it result in silent failures. In Python (and other OO language), you don't return errors, you must raise exceptions.

More about exceptions:
http://www.python.org/doc/current/tut/node10.html

Change History (5)

comment:1 Changed 7 years ago by olivier

  • Owner set to yomguy

comment:2 Changed 7 years ago by anonymous

In r126, I see you call raise with strings... This isn't right. String exceptions are a bad practice, they can't be properly caught and are deprecated in Python 2.5.

Please use class exceptions, as explained in "8.4 Raising Exceptions" and "8.5 User-defined Exceptions", in the tutorial page I mention in my report.

comment:3 Changed 7 years ago by olivier

By the way, if you need to define custom ("User-defined") exceptions, you should put the class definitions in export/api.py, so that one knows what exceptions to expect from the export package, what specific attributes these exceptions carry, etc..

comment:4 Changed 5 years ago by yomguy

  • Milestone set to 0.4

comment:5 Changed 5 years ago by yomguy

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.