Skip to content

Commit

Permalink
patch: actualizado workflow y mejoras de código
Browse files Browse the repository at this point in the history
* Se actualiza version de actions/checkout
* Mejorada lectura de código en logger.utils.ts
* Se agregan "migas" de sentry al recibir errores
  • Loading branch information
Im-Fran committed May 3, 2024
1 parent 7bd0e74 commit 1684b46
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node Tests
name: Node Test

on:
push:
Expand All @@ -20,7 +17,7 @@ jobs:
node-version: [18, 20]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: 'Setup Node.js'
uses: actions/setup-node@v4
with:
Expand Down
20 changes: 14 additions & 6 deletions src/infrastructure/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ export default class Server {
res: Response,
next: NextFunction
) {
GenericLogger.log({
level: "error",
message: err.stack,
});
if (err instanceof GenericError) {
let uid: string;
try {
Expand All @@ -103,10 +99,21 @@ export default class Server {
}
}

console.error({
Sentry.addBreadcrumb({
category: 'error',
message: 'Obtuvimos un error de tipo "GenericError" en el servidor',
error: err,
level: 'error',
data: {
error: err,
uid,
}
})


GenericLogger.log({
level: "error",
message: err.stack,
});
res.statusCode = err.statusCode;
res.json({
codigoHttp: err.statusCode ? err.statusCode : 500,
Expand All @@ -115,6 +122,7 @@ export default class Server {
error: err.message,
});
} else {
Sentry.captureException(err);
res.statusCode = 500;
res.json({
codigoHttp: 500,
Expand Down
8 changes: 1 addition & 7 deletions src/infrastructure/utils/logger.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ export default class GenericLogger {
],
});

public static log({
level = "info",
message = "",
}: {
level?: string;
message?: string;
}) {
public static log({ level = "info", message = "" }: { level?: string; message?: string; }) {
this.logger.log({level, message});
}
}

0 comments on commit 1684b46

Please sign in to comment.