Remplacement des codes d'erreurs NotAcceptable par des codes plus adaptés

This commit is contained in:
2024-12-08 17:02:22 +01:00
parent 3af1e498ac
commit 83d3a573ca
6 changed files with 13 additions and 16 deletions

View File

@ -1,7 +1,7 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, ParseIntPipe, HttpCode, UseGuards, Req, Query, NotFoundException } from '@nestjs/common'
import { ChallengeActionsService } from './challenge-actions.service'
import { AuthenticatedRequest, JwtAuthGuard } from 'src/auth/jwt-auth.guard'
import { ApiBearerAuth, ApiCreatedResponse, ApiNotFoundResponse, ApiOkResponse, ApiUnauthorizedResponse, ApiUnprocessableEntityResponse } from '@nestjs/swagger'
import { ApiBearerAuth, ApiConflictResponse, ApiCreatedResponse, ApiNotFoundResponse, ApiOkResponse, ApiUnauthorizedResponse } from '@nestjs/swagger'
import { ChallengeActionEntity } from './entities/challenge-action.entity'
import { CreateChallengeActionDto } from './dto/create-challenge-action.dto'
import { ApiOkResponsePaginated, paginateOutput } from 'src/common/utils/pagination.utils'
@ -76,6 +76,7 @@ export class ChallengeActionsController {
@ApiOkResponse({ type: ChallengeActionEntity })
@ApiUnauthorizedResponse({ description: "Non authentifié⋅e" })
@ApiNotFoundResponse({ description: "Objet non trouvé" })
@ApiConflictResponse({ description: "Aucun défi à terminer n'est en cours" })
async endCurrent(@Req() request: AuthenticatedRequest, @Body() { success }: EndChallengeActionDto): Promise<ChallengeActionEntity> {
const challengeAction = await this.challengeActionsService.endCurrentChallenge(request.user, success)
return new ChallengeActionEntity(challengeAction)

View File

@ -1,4 +1,4 @@
import { Injectable, NotAcceptableException } from '@nestjs/common'
import { BadRequestException, Injectable, UnprocessableEntityException } from '@nestjs/common'
import { CreateChallengeActionDto } from './dto/create-challenge-action.dto'
import { UpdateChallengeActionDto } from './dto/update-challenge-action.dto'
import { ChallengeAction, Player } from '@prisma/client'
@ -55,7 +55,7 @@ export class ChallengeActionsService {
}
})
if (!challengeAction)
throw new NotAcceptableException("Aucun défi n'est en cours")
throw new BadRequestException("Aucun défi n'est en cours")
let data
const now = new Date()
if (success) {