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> => { return async (config: ServiceConfig): Promise<ServiceData> => {
const value = handler(config); const value = handler(config);
if (isPromise(value) === true) { if (isPromise(value) === true) {
return (value as Promise<ServiceData>).then((data: ServiceData) => { return (value as Promise<ServiceData>)
if (data.status != undefined) { .then((data: ServiceData) => {
return data; if (data.status != undefined) {
} return data;
return pollGeneric(data, config.url); }
}); 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); return pollGeneric(value as ServiceData, config.url);
}; };