diff --git a/src/models/controller.model.ts b/src/models/controller.model.ts index 9c03f622..9e481f3d 100644 --- a/src/models/controller.model.ts +++ b/src/models/controller.model.ts @@ -120,10 +120,10 @@ export class Controller { res.status(200).send(responseContacts); } catch (error) { - // prevent logging of refresh errors + // prevent logging of integration errors that are forwarded to the client if ( error instanceof ServerError && - error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR + error.message in IntegrationErrorType ) { next(error); return; @@ -185,17 +185,18 @@ export class Controller { } } } catch (error) { - // prevent logging of refresh errors + // prevent logging of integration errors that are forwarded to the client if ( error instanceof ServerError && - error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR + error.message in IntegrationErrorType ) { next(error); return; } - console.error( + errorLogger( `[${anonymizeKey(apiKey)}] Could not create contact`, + req.providerConfig, error || "Unknown" ); next(error); @@ -252,16 +253,20 @@ export class Controller { } } } catch (error) { - // prevent logging of refresh errors + // prevent logging of integration errors that are forwarded to the client if ( error instanceof ServerError && - error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR + error.message in IntegrationErrorType ) { next(error); return; } - console.error("Could not update contact:", error || "Unknown"); + errorLogger( + "Could not update contact:", + req.providerConfig, + error || "Unknown" + ); next(error); } } @@ -302,16 +307,20 @@ export class Controller { } } } catch (error) { - // prevent logging of refresh errors + // prevent logging of integration errors that are forwarded to the client if ( error instanceof ServerError && - error.message === IntegrationErrorType.INTEGRATION_REFRESH_ERROR + error.message in IntegrationErrorType ) { next(error); return; } - console.error("Could not delete contact:", error || "Unknown"); + errorLogger( + "Could not delete contact:", + req.providerConfig, + error || "Unknown" + ); next(error); } } diff --git a/src/models/integration-error.model.ts b/src/models/integration-error.model.ts index a1c79e6d..7361450d 100644 --- a/src/models/integration-error.model.ts +++ b/src/models/integration-error.model.ts @@ -1,6 +1,7 @@ export enum IntegrationErrorType { INTEGRATION_INVALID_URL = "integration/invalid-url", INTEGRATION_REFRESH_ERROR = "integration/refresh-error", + INTEGRATION_ACCOUNT_EXPIRED_ERROR = "integration/account-expired-error", CONTACT_CREATE_ERROR_CONFLICT = "contact/create-error/conflict", CONTACT_CREATE_ERROR_EMAIL_CONFLICT = "contact/create-error/email-conflict", CONTACT_ERROR_TOO_MANY_NUMBERS = "contact/error/too-many-numbers",