Skip to content

Commit

Permalink
🔊 improve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonaOna committed Oct 19, 2023
1 parent 52161b7 commit eccb98a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/models/controller.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,17 @@ export class Controller {
}

if (this.adapter.getToken && req.providerConfig) {
const { apiKey } = await this.adapter.getToken(req.providerConfig);
res.header('X-Provider-Key', apiKey);
try {
const { apiKey } = await this.adapter.getToken(req.providerConfig);
res.header('X-Provider-Key', apiKey);
} catch (error) {
errorLogger(
'getContacts',
'Could not get and refresh token',
providerConfig.apiKey,
error,
);
}
}

infoLogger('getContacts', 'END', providerConfig.apiKey);
Expand Down Expand Up @@ -374,8 +383,17 @@ export class Controller {
this.streamingPromises.set(`${userId}:${timestamp}`, streamingPromise);

if (this.adapter.getToken && req.providerConfig) {
const { apiKey } = await this.adapter.getToken(req.providerConfig);
res.header('X-Provider-Key', apiKey);
try {
const { apiKey } = await this.adapter.getToken(req.providerConfig);
res.header('X-Provider-Key', apiKey);
} catch (error) {
errorLogger(
'streamContacts',
'Could not get and refresh token',
providerConfig.apiKey,
error,
);
}
}

infoLogger('streamContacts', 'END', providerConfig.apiKey);
Expand Down

0 comments on commit eccb98a

Please sign in to comment.