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

Pass errors to cluster function callbacks #9251

Merged
merged 2 commits into from
Feb 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/source/geojson_worker_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,36 @@ class GeoJSONWorkerSource extends VectorTileWorkerSource {
}

getClusterExpansionZoom(params: {clusterId: number}, callback: Callback<number>) {
callback(null, this._geoJSONIndex.getClusterExpansionZoom(params.clusterId));
let result;

try {
result = this._geoJSONIndex.getClusterExpansionZoom(params.clusterId);
callback(null, result);
} catch (e) {
callback(e, result);
}
}

getClusterChildren(params: {clusterId: number}, callback: Callback<Array<GeoJSONFeature>>) {
callback(null, this._geoJSONIndex.getChildren(params.clusterId));
let result;

try {
result = this._geoJSONIndex.getChildren(params.clusterId);
callback(null, result);
} catch (e) {
callback(e, result);
}
}

getClusterLeaves(params: {clusterId: number, limit: number, offset: number}, callback: Callback<Array<GeoJSONFeature>>) {
callback(null, this._geoJSONIndex.getLeaves(params.clusterId, params.limit, params.offset));
let result;

try {
result = this._geoJSONIndex.getLeaves(params.clusterId, params.limit, params.offset);
callback(null, result);
} catch (e) {
callback(e, result);
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: there's no need to define result outside of try — just do callback(e), since it will be undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, good point

}
}

Expand Down