Permalink
Browse files

Added several more error wrappersA

  • Loading branch information...
1 parent 0f07abe commit 596a3c56295a5722b0fb7dd7790925de814761dd @guyrt guyrt committed Apr 4, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 ofxparse/ofxparse.py
View
@@ -287,7 +287,7 @@ def parseInvestmentPosition(cls_, ofx):
if (hasattr(tag, 'contents')):
try:
position.date = cls_.parseOfxDateTime(tag.contents[0].strip())
- except TypeError:
+ except ValueError:
raise
return position
@@ -304,13 +304,13 @@ def parseInvestmentTransaction(cls_, ofx):
if (hasattr(tag, 'contents')):
try:
transaction.tradeDate = cls_.parseOfxDateTime(tag.contents[0].strip())
- except TypeError:
+ except ValueError:
raise
tag = ofx.find('dtsettle')
if (hasattr(tag, 'contents')):
try:
transaction.settleDate = cls_.parseOfxDateTime(tag.contents[0].strip())
- except TypeError:
+ except ValueError:
raise
tag = ofx.find('uniqueid')
if (hasattr(tag, 'contents')):
@@ -340,13 +340,21 @@ def parseInvestmentStatement(cls_, invstmtrs_ofx):
statement.warnings.append(u'Empty start date.')
if cls_.fail_fast:
raise
+ except ValueError as e:
+ statement.warnings.append(u'Invalid start date: %s' % e)
+ if cls_.fail_fast:
+ raise
tag = invtranlist_ofx.find('dtend')
if (hasattr(tag, 'contents')):
try:
statement.end_date = cls_.parseOfxDateTime(tag.contents[0].strip())
except IndexError:
statement.warnings.append(u'Empty end date.')
+ except ValueError as e:
+ statement.warnings.append(u'Invalid end date: %s' % e)
+ if cls_.fail_fast:
+ raise
try:
for investment_ofx in invstmtrs_ofx.findAll('posmf'):
@@ -417,7 +425,7 @@ def parseStatement(cls_, stmt_ofx):
statement.warnings.append(u"Statement start date was empty for %s" % stmt_ofx)
if cls_.fail_fast:
raise
- except TypeError:
+ except ValueError:
statement.warnings.append(u"Statement start date was not allowed for %s" % stmt_ofx)
if cls_.fail_fast:
raise
@@ -439,7 +447,7 @@ def parseStatement(cls_, stmt_ofx):
statement.warnings.append(u"Statement start date was not allowed for %s" % stmt_ofx)
if cls_.fail_fast:
raise
-
+
currency_tag = stmt_ofx.find('curdef')
if hasattr(currency_tag, "contents"):
try:

0 comments on commit 596a3c5

Please sign in to comment.