Skip to content

Commit

Permalink
In python 3, the Exceptions don't have the attribute message. It's be…
Browse files Browse the repository at this point in the history
…en replaced by args. The Exception by itself is a string, and that's what I have decided to use as is.

Signed-off-by: Lincoln Simba <[email protected]>
  • Loading branch information
lincmba committed May 28, 2019
1 parent 2aa1e5e commit e1fbbd2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion onadata/apps/logger/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def form_upload(request, username):
else:
content = xform['text']
if isinstance(content, Exception):
content = content.message
content = content
status = 500
else:
status = 400
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/sms_support/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def media_value(value, medias):
# check that altitude is integer
int(geodata[2])
except Exception as e:
raise SMSCastingError(e.message, xlsf_name)
raise SMSCastingError(e, xlsf_name)
return " ".join(geodata)

elif xlsf_type in MEDIA_TYPES:
Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def authenticate(self, request):
raise AuthenticationFailed(
_('Invalid username/password'))
except (AttributeError, ValueError, DataError) as e:
raise AuthenticationFailed(e.message)
raise AuthenticationFailed(e)

def authenticate_header(self, request):
response = self.authenticator.build_challenge_response()
Expand Down
4 changes: 2 additions & 2 deletions onadata/libs/serializers/stats_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def to_representation(self, obj):
data = get_form_submissions_grouped_by_field(
obj, field, name)
except ValueError as e:
raise exceptions.ParseError(detail=e.message)
raise exceptions.ParseError(detail=e)
else:
if data:
element = obj.get_survey_element(field)
Expand Down Expand Up @@ -93,6 +93,6 @@ def to_representation(self, obj):
try:
data = stats_function(obj, field)
except ValueError as e:
raise exceptions.ParseError(detail=e.message)
raise exceptions.ParseError(detail=e)

return data
2 changes: 1 addition & 1 deletion onadata/libs/serializers/xform_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _create_enketo_url(request, xform):
url = enketo_url(form_url, xform.id_string)
MetaData.enketo_url(xform, url)
except ConnectionError as e:
logging.exception("Connection Error: %s" % e.message)
logging.exception("Connection Error: %s" % e)
except EnketoError as e:
logging.exception("Enketo Error: %s" % e.message)

Expand Down
2 changes: 1 addition & 1 deletion script/i18ntool.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def main():
if lang not in LANGS:
raise ValueError(u"Unknown lang code")
except ValueError as e:
puts(colored.red(e.message))
puts(colored.red(e))
usage()
except IndexError:
lang = None
Expand Down

0 comments on commit e1fbbd2

Please sign in to comment.