Skip to content

Commit

Permalink
feat: added catch for endpoint errors
Browse files Browse the repository at this point in the history
cmoinier authored and jahow committed May 6, 2024
1 parent ff34487 commit ee7cca2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions libs/feature/dataviz/src/lib/service/data.service.ts
Original file line number Diff line number Diff line change
@@ -174,8 +174,30 @@ export class DataService {

async getDownloadUrlsFromOgcApi(url: string): Promise<OgcApiCollectionInfo> {
const endpoint = new OgcApiEndpoint(this.proxy.getProxiedUrl(url))
const collection = (await endpoint.featureCollections)[0]
return endpoint.getCollectionInfo(collection)
return await endpoint.featureCollections
.then((collections) => {
return endpoint.getCollectionInfo(collections[0])
})
.catch((error) => {
if (error instanceof Error) {
throw new Error(`wfs.unreachable.unknown`)
} else {
if (error.type === 'network') {
throw new Error(`wfs.unreachable.cors`)
}
if (error.type === 'http') {
throw new Error(`wfs.unreachable.http`)
}
if (error.type === 'parse') {
throw new Error(`wfs.unreachable.parse`)
}
if (error.type === 'unsupportedType') {
throw new Error(`wfs.unreachable.unsupportedType`)
} else {
throw new Error(`wfs.unreachable.unknown`)
}
}
})
}

getDownloadLinksFromEsriRest(

0 comments on commit ee7cca2

Please sign in to comment.