Commit 3af9064e authored by Tobias Steiner's avatar Tobias Steiner
Browse files

Change errorhandling

parent 119c33e4
Pipeline #3126 passed with stage
in 2 minutes and 45 seconds
......@@ -180,7 +180,12 @@ export class ApiController {
// todo: we should use rxjs here
let unsubscribeTimer: Timer = null;
async function waitForResponse(data: InterfaceStreamAppResponse) {
await responseData.add(data);
// if we fail to resolve the url to a provider we will send a 500
try {
await responseData.add(data);
} catch (error) {
return next(Boom.internal('Unable to resolve urls to provider'));
}
if (responseData.finished()) {
// set the cache each time we got new data and have at least a minimum set
KafkaCache.set(id, responseData.getData());
......
......@@ -57,15 +57,9 @@ export class ResponseCollector {
if(Array.isArray(data.data.links)) {
data.data.links = await Promise.all(data.data.links.map(async (d) => {
const a = {};
try {
const provider = await UrlResolver.getProvider(d, this.language);
a[provider] = d;
return a;
} catch(error) {
console.log(`error getting provider` + error);
a['unknown'] = d;
return a;
}
const provider = await UrlResolver.getProvider(d, this.language);
a[provider] = d;
return a;
}));
}
if(Array.isArray(this.finalData.data[data.name])) {
......
......@@ -14,8 +14,11 @@ class UrlResolver {
const provider = await axios.get(UrlResolver.baseUrl + url);
return provider.data.name[language];
} catch(err) {
console.log(`Could not resolve url ${url}`, err);
return 'unknown';
if(err.response.status === 404) {
console.log(`Could not resolve (404) url ${url}`);
return 'unknown';
}
throw new Error(`Could not resolve (${err.response.status}) url ${url}`);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment