Skip to content

Commit

Permalink
Checking for errors in dr-manhattan
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlueders committed Jan 5, 2017
1 parent 637618b commit 1ff0336
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions services/util/sentiment_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def tokenize(self, caption, lang):
try:
return filter(lambda x: len(x)>1, Text(caption).words)
except:
print caption
print 'error in tokenize returning empty array'
return []
else:
return []
Expand All @@ -48,7 +48,7 @@ def pres_tokenize(self, caption, lang):
caption = re.sub('[#]', ' #',caption,flags=re.UNICODE)
return filter(lambda x: len(x)>1, Text(caption).words)
except:
print caption
print 'error in pres_tokenize returning empty array'
return []
else:
return []
Expand Down

1 comment on commit 1ff0336

@lukewendling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinlueders @drJAGartner can I raise a cpl of concerns here. bear with me.

  • what happens when someone changes the function name but forgets to the change error message? ... will be confusing when debugging.
  • why not just print the stacktrace to fix the above? it has the same effect, namely telling us where the error occurred, and it isn't as brittle.
  • generically handling an error and printing a message assumes that only 1 type of error will ever occur on those line(s), which again is misleading, and can be a time killer to track down.

to solve all this, I'm proposing that we print stacktraces + print the err message, for such error handling scenarios.

Proposal

print(e)
import traceback
traceback.print_exc()

Please sign in to comment.