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

try/catch extent() #124

Merged
merged 3 commits into from
May 6, 2015
Merged

try/catch extent() #124

merged 3 commits into from
May 6, 2015

Conversation

missinglink
Copy link
Member

try/catch for the issue causing pelias/pelias#84

updates dependency which should prevent the above try/catch from firing, issue should now be resolved.
ref: caseycesari/GeoJSON.js#12

resolves #84

@sevko
Copy link
Contributor

sevko commented May 6, 2015

Can you add a block comment documenting why that try/catch is there, just in case we forget to remove it and somebody stumbles across it at a later point?

@@ -62,7 +62,12 @@ function search( docs, params ){
var geojson = GeoJSON.parse( geodata, { Point: ['lat', 'lng'] });

// add bbox
geojson.bbox = extent( geojson ) || undefined;
try {
geojson.bbox = extent( geojson ) || undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks a bit odd to have the || conditional inside a try/catch and after the thing that might throw. would be cleaner as

geojson.bbox = undefined;
try {
  geojson.bbox = extent( geojson )
}
catch (e) {
  // ...
}

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, I think this is because extent() can return null which ends up in the JSON payload, I totally agree it doesn't feel right, will give it a rejig.

@dianashk
Copy link
Contributor

dianashk commented May 6, 2015

thanks for the rejig. 👍

@sevko
Copy link
Contributor

sevko commented May 6, 2015

+1

missinglink added a commit that referenced this pull request May 6, 2015
@missinglink missinglink merged commit 758b8fa into master May 6, 2015
@missinglink
Copy link
Member Author

$ npm publish
npm http PUT https://registry.npmjs.org/pelias-api
npm http 200 https://registry.npmjs.org/pelias-api
+ pelias-api@1.2.0

@sevko sevko deleted the issue84 branch May 11, 2015 14:49
@riordan riordan added the v1 label Aug 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

suggest and reverse problems
4 participants