Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BGDIINF_SB-2238: Improved error handling - avoid 500 errors on bad request #107

Merged
merged 2 commits into from
May 5, 2022

Conversation

ltshb
Copy link
Contributor

@ltshb ltshb commented May 5, 2022

Avoiding 500 error when the request parameters are invalid.

Only LineString and Point are supported as input geometry. Checking this
avoid later crash.

Removed also broad exception by using correct exception type.

Point and LineString shape is_valid is a property and not a function
and do not raise exception but simply return True or False. Before this
kind of invalid shape object where caught later by trying to guess the
srid.

@github-actions github-actions bot added the bug label May 5, 2022
@ltshb ltshb requested review from ltkum and procrastinatio May 5, 2022 11:52
@ltshb ltshb force-pushed the bug-BGDIINF_SB-2238-crash-with-invalid-data branch from f36d045 to 0e3b762 Compare May 5, 2022 12:04
Copy link
Contributor

@ltkum ltkum left a comment

Choose a reason for hiding this comment

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

Solid work as usual.

Only thing I could find where I would prefer a change would be a method name, but this is mostly a matter of personal preference at this point. Feel free to merge.

@@ -38,3 +41,13 @@ def srs_guesser(geom):
sr = epsg
break
return sr


def validate_sr(sr):
Copy link
Contributor

Choose a reason for hiding this comment

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

I kinda feel that "validate_spatial_reference" would be clearer and easier to read. But if you prefer to keep the method original name, no problem with me.

@ltshb ltshb closed this May 5, 2022
@ltshb ltshb force-pushed the bug-BGDIINF_SB-2238-crash-with-invalid-data branch from c391c00 to dbb8631 Compare May 5, 2022 13:37
ltshb added 2 commits May 5, 2022 15:41
…quest

Avoiding 500 error when the request parameters are invalid.

Only LineString and Point are supported as input geometry. Checking this
avoid later crash.

Removed also broad exception by using correct exception type.

Point and LineString shape `is_valid` is a property and not a function
and do not raise exception but simply return True or False. Before this
kind of invalid shape object where caught later by trying to guess the
srid.
@ltshb ltshb reopened this May 5, 2022
@ltshb ltshb merged commit fad34af into develop May 5, 2022
@ltshb ltshb deleted the bug-BGDIINF_SB-2238-crash-with-invalid-data branch May 5, 2022 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants