Skip to content

Commit

Permalink
fix(error): reuse errors definition
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel committed Apr 4, 2024
1 parent 05ab9cc commit ed45a64
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 75 deletions.
14 changes: 5 additions & 9 deletions packages/server/lib/controllers/appAuth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ class AppAuthController {
};

if (missesInterpolationParam(tokenUrl, connectionConfig)) {
const error = WSErrBuilder.InvalidConnectionConfig(tokenUrl, JSON.stringify(connectionConfig));
await createActivityLogMessage({
level: 'error',
environment_id: environmentId,
activity_log_id: activityLogId as number,
content: WSErrBuilder.InvalidConnectionConfig(tokenUrl, JSON.stringify(connectionConfig)).message,
content: error.message,
timestamp: Date.now(),
auth_mode: template.auth_mode,
url: req.originalUrl,
Expand All @@ -144,13 +145,7 @@ class AppAuthController {
}
});

return publisher.notifyErr(
res,
wsClientId,
providerConfigKey,
connectionId,
WSErrBuilder.InvalidConnectionConfig(tokenUrl, JSON.stringify(connectionConfig))
);
return publisher.notifyErr(res, wsClientId, providerConfigKey, connectionId, error);
}

if (!installation_id) {
Expand Down Expand Up @@ -245,7 +240,8 @@ class AppAuthController {
} catch (err) {
const prettyError = JSON.stringify(err, ['message', 'name'], 2);

const content = WSErrBuilder.UnknownError().message + '\n' + prettyError;
const error = WSErrBuilder.UnknownError();
const content = error.message + '\n' + prettyError;

await createActivityLogMessage({
level: 'error',
Expand Down
Loading

0 comments on commit ed45a64

Please sign in to comment.