Skip to content

Commit

Permalink
fix(log): errors not being logged correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jagregory committed Jan 11, 2022
1 parent c726194 commit 1ca2b99
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/bin/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ createDefaultServer(logger)
logger.info(`Cognito Local running on http://${url}`);
})
.catch((err) => {
logger.error({ error: err });
logger.error(err);
process.exit(1);
});
4 changes: 2 additions & 2 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ export const createServer = (
unsupported(ex.message, res, req.log);
return;
} else if (ex instanceof CognitoError) {
req.log.warn({ error: ex }, `Error handling target: ${target}`);
req.log.warn(ex, `Error handling target: ${target}`);
res.status(400).json({
code: ex.code,
message: ex.message,
});
return;
} else {
req.log.error({ error: ex }, `Error handling target: ${target}`);
req.log.error(ex, `Error handling target: ${target}`);
res.status(500).json(ex);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/services/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class LambdaService implements Lambda {
})
.promise();
} catch (ex) {
ctx.logger.error({ error: ex });
ctx.logger.error(ex);
throw new UnexpectedLambdaExceptionError();
}

Expand All @@ -239,11 +239,11 @@ export class LambdaService implements Lambda {

return parsedPayload.response;
} catch (err) {
ctx.logger.error({ error: err });
ctx.logger.error(err);
throw new InvalidLambdaResponseError();
}
} else {
ctx.logger.error({ error: result.FunctionError });
ctx.logger.error(result.FunctionError);
throw new UserLambdaValidationError(result.FunctionError);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/triggers/customMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const CustomMessage =
.replace(AWS_USERNAME_PARAMETER, username),
};
} catch (ex) {
ctx.logger.error({ error: ex });
ctx.logger.error(ex);
return null;
}
};
2 changes: 1 addition & 1 deletion src/services/triggers/postAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export const PostAuthentication =
userPoolId,
});
} catch (err) {
ctx.logger.warn({ error: err }, "PostAuthentication error, ignored");
ctx.logger.warn(err, "PostAuthentication error, ignored");
}
};
2 changes: 1 addition & 1 deletion src/services/triggers/postConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ export const PostConfirmation =
userPoolId,
});
} catch (ex) {
ctx.logger.error({ error: ex });
ctx.logger.error(ex);
}
};

0 comments on commit 1ca2b99

Please sign in to comment.