Skip to content

Commit 6005fb0

Browse files
committed
👔 Dont log refresh errors
1 parent 6de829e commit 6005fb0

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/models/controller.model.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { APIContact } from "./api-contact.model";
2222
import { CacheItemStateType } from "./cache-item-state.model";
2323
import { CalendarFilterOptions } from "./calendar-filter-options.model";
2424
import { errorLogger, infoLogger } from "../util/logger.util";
25+
import { IntegrationErrorType } from "./integration-error.model";
2526

2627
const CONTACT_FETCH_TIMEOUT: number = 3000;
2728

@@ -114,6 +115,15 @@ export class Controller {
114115

115116
res.status(200).send(responseContacts);
116117
} catch (error) {
118+
// prevent logging of refresh errors
119+
if (
120+
error instanceof ServerError &&
121+
error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR
122+
) {
123+
next(error);
124+
return;
125+
}
126+
117127
errorLogger(
118128
"Could not get contacts:",
119129
providerConfig,
@@ -170,6 +180,15 @@ export class Controller {
170180
}
171181
}
172182
} catch (error) {
183+
// prevent logging of refresh errors
184+
if (
185+
error instanceof ServerError &&
186+
error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR
187+
) {
188+
next(error);
189+
return;
190+
}
191+
173192
console.error(
174193
`[${anonymizeKey(apiKey)}] Could not create contact`,
175194
error || "Unknown"
@@ -228,6 +247,15 @@ export class Controller {
228247
}
229248
}
230249
} catch (error) {
250+
// prevent logging of refresh errors
251+
if (
252+
error instanceof ServerError &&
253+
error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR
254+
) {
255+
next(error);
256+
return;
257+
}
258+
231259
console.error("Could not update contact:", error || "Unknown");
232260
next(error);
233261
}
@@ -269,6 +297,15 @@ export class Controller {
269297
}
270298
}
271299
} catch (error) {
300+
// prevent logging of refresh errors
301+
if (
302+
error instanceof ServerError &&
303+
error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR
304+
) {
305+
next(error);
306+
return;
307+
}
308+
272309
console.error("Could not delete contact:", error || "Unknown");
273310
next(error);
274311
}

0 commit comments

Comments
 (0)