Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Add some more context around upload errors
Browse files Browse the repository at this point in the history
* Add a data_group and data_type field for easier filtering
* Add a backdrop_upload_error field - I would like to add a tag but the
  logstash formatter we use doesnt support this
* Log the exception info as well
  • Loading branch information
timmow committed Jul 16, 2014
1 parent f252729 commit fc09ace
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backdrop/admin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,29 @@ def _store_data(data_set_config):
raw_data = parse_file(uploaded_file.file_stream())
data_set.post(raw_data)
except expected_errors as e:
app.logger.error('Upload error: {}'.format(e.message))
log_upload_error('Upload error', app, e, data_set_config)
return render_template('upload_error.html',
message=e.message,
data_set_name=data_set_config.name), 400
except RequestException as e:
log_upload_error('Error writing to backdrop', app, e, data_set_config)
abort(500, 'Error saving to datastore: "{}"'.format(e.message))

return render_template('upload_ok.html')


def log_upload_error(message, app, e, data_set_config):
app.logger.error(
'{}: {}'.format(message, e.message),
extra={
'backdrop_upload_error': type(e).__name__,
'data_group': data_set_config.data_group,
'data_type': data_set_config.data_type,
},
exc_info=True
)


def start(port):
app.debug = True
app.run('0.0.0.0', port=port)

0 comments on commit fc09ace

Please sign in to comment.