Skip to content

Commit

Permalink
Merge pull request #269 from internxt/bug/PB-1617
Browse files Browse the repository at this point in the history
[PB-1617] chore: add logs in empty trash endpoints
  • Loading branch information
sg-gs authored Feb 8, 2024
2 parents f1ae0c2 + 4886bad commit c8485e1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/modules/trash/trash.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Logger,
HttpStatus,
UseFilters,
InternalServerErrorException,
} from '@nestjs/common';
import {
ApiBadRequestResponse,
Expand Down Expand Up @@ -191,13 +192,33 @@ export class TrashController {
summary: "Deletes all items from user's trash",
})
async clearTrash(@UserDecorator() user: User) {
await this.trashUseCases.emptyTrash(user);
try {
await this.trashUseCases.emptyTrash(user);
} catch (error) {
new Logger().error(
`[TRASH/EMPTY_TRASH] ERROR: ${
(error as Error).message
} USER: ${JSON.stringify(user)} STACK: ${(error as Error).stack}`,
);

throw new InternalServerErrorException();
}
}

@UseFilters(new HttpExceptionFilter())
@Delete('/all/request')
requestEmptyTrash(user: User) {
this.trashUseCases.emptyTrash(user);
try {
this.trashUseCases.emptyTrash(user);
} catch (error) {
new Logger().error(
`[TRASH/REQUEST_EMPTY_TRASH] ERROR: ${
(error as Error).message
} USER: ${JSON.stringify(user)} STACK: ${(error as Error).stack}`,
);

throw new InternalServerErrorException();
}
}

@Delete('/')
Expand Down

0 comments on commit c8485e1

Please sign in to comment.