Skip to content

Conversation

amymok
Copy link
Contributor

@amymok amymok commented Jul 6, 2017

This PR includes code to catch any elasticsearch errors from the es_interface, and handle them gracefully with 400 errors. This should prevent any unnecessary 500 error for the user.

Additions:

  • Add try/catch block for all endpoints to handle Elasticsearch Transport errors

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling af731c1 on amymok:catch-errors into 1e49d84 on cfpb:master.

res = {
"error": 'Elasticsearch error: ' + e.error
}
return Response(res, status=status_code)
Copy link
Contributor

Choose a reason for hiding this comment

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

This block is essentially duplicated three times. May want to rewrite as a wrapper function? Or a decorated method?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling bc676a6 on amymok:catch-errors into 1e49d84 on cfpb:master.

@amymok
Copy link
Contributor Author

amymok commented Jul 7, 2017

@JeffreyMFarley That was a great suggestion, I moved that block to a decorator now.

Copy link
Contributor

@JeffreyMFarley JeffreyMFarley left a comment

Choose a reason for hiding this comment

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

That's the stuff!

@amymok amymok merged commit f2a3503 into cfpb:master Jul 7, 2017
AdamZarger pushed a commit to AdamZarger/ccdb5-api that referenced this pull request Sep 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants