Skip to content

Commit

Permalink
fix: change status error
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonwea committed Nov 27, 2023
1 parent f32976b commit 765ff96
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/http/controllers/users/update-profile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NicknameAlreadyExitsError } from '@/use-cases/errors/nickname-already-exists-error'
import { makeUpdateUserProfileUseCase } from '@/use-cases/factories/users/make-update-user-profile-use-case'
import { FastifyReply, FastifyRequest } from 'fastify'
import { undefined, z } from 'zod'
Expand Down Expand Up @@ -29,8 +30,8 @@ export async function updateProfile(
password_hash: undefined,
})
} catch (err) {
if (err instanceof Error) {
return reply.status(400).send({ message: err.message })
if (err instanceof NicknameAlreadyExitsError) {
return reply.status(409).send({ message: err.message })
}

throw err
Expand Down

0 comments on commit 765ff96

Please sign in to comment.