Make sure we catch everything while polling.

Also fall back to check simply the URL if it fails to do the real service.
This commit is contained in:
2023-09-21 11:24:51 +02:00
parent 93b663c2c8
commit 397b632b56

View File

@@ -27,12 +27,17 @@ function wrapHandler(handler: ServiceHandler): AsyncServiceHandler {
return async (config: ServiceConfig): Promise<ServiceData> => {
const value = handler(config);
if (isPromise(value) === true) {
return (value as Promise<ServiceData>).then((data: ServiceData) => {
if (data.status != undefined) {
return data;
}
return pollGeneric(data, config.url);
});
return (value as Promise<ServiceData>)
.then((data: ServiceData) => {
if (data.status != undefined) {
return data;
}
return pollGeneric(data, config.url);
})
.catch((error) => {
console.warn("could not resolve service '" + config.url + "': " + error);
return pollGeneric({}, config.url);
});
}
return pollGeneric(value as ServiceData, config.url);
};