Skip to content

Commit

Permalink
fix(geom-filter): warn user only if the geometry if not valid
Browse files Browse the repository at this point in the history
while previous code was warning even if the geometry service returns an error
  • Loading branch information
fgravin committed Nov 29, 2023
1 parent d8f4aa4 commit 650eab0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions libs/feature/search/src/lib/state/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,21 @@ export class SearchEffects {
}
return this.filterGeometry$.pipe(
tap((geom) => {
const isValid = validGeoJson(geom)
if (!isValid) {
throw '\nFilter geometry is not a valid GeoJson'
try {
const trace = validGeoJson(geom, true) as string[]
if (trace?.length > 0) {
throw new Error(trace.join('\n'))
}
} catch (error) {
console.warn(
'Error while parsing the geometry filter\n',
error
)
throw new Error()
}
}),
map((geom) => [state, favorites, geom]),
catchError((e) => {
console.warn('The filter geometry cannot be used', e)
return of([state, favorites, null])
}) // silently opt out of spatial filter if an error happens
)
Expand Down

0 comments on commit 650eab0

Please sign in to comment.