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:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user