@@ -2,7 +2,7 @@ import { FastifyInstance, FastifyRequest } from 'fastify'
22import { PostgresMeta } from '../../lib'
33import * as Parser from '../../lib/Parser'
44import { DEFAULT_POOL_CONFIG } from '../constants'
5- import { extractRequestForLogging } from '../utils'
5+ import { extractRequestForLogging , translateErrorToResponseCode } from '../utils'
66
77const errorOnEmptyQuery = ( request : FastifyRequest ) => {
88 if ( ! ( request . body as any ) . query ) {
@@ -25,7 +25,7 @@ export default async (fastify: FastifyInstance) => {
2525 await pgMeta . end ( )
2626 if ( error ) {
2727 request . log . error ( { error, request : extractRequestForLogging ( request ) } )
28- reply . code ( 400 )
28+ reply . code ( translateErrorToResponseCode ( error ) )
2929 return { error : error . message }
3030 }
3131
@@ -43,7 +43,7 @@ export default async (fastify: FastifyInstance) => {
4343
4444 if ( error ) {
4545 request . log . error ( { error, request : extractRequestForLogging ( request ) } )
46- reply . code ( 400 )
46+ reply . code ( translateErrorToResponseCode ( error ) )
4747 return { error : error . message }
4848 }
4949
@@ -61,7 +61,7 @@ export default async (fastify: FastifyInstance) => {
6161
6262 if ( error ) {
6363 request . log . error ( { error, request : extractRequestForLogging ( request ) } )
64- reply . code ( 400 )
64+ reply . code ( translateErrorToResponseCode ( error ) )
6565 return { error : error . message }
6666 }
6767
@@ -78,7 +78,7 @@ export default async (fastify: FastifyInstance) => {
7878
7979 if ( error ) {
8080 request . log . error ( { error, request : extractRequestForLogging ( request ) } )
81- reply . code ( 400 )
81+ reply . code ( translateErrorToResponseCode ( error ) )
8282 return { error : error . message }
8383 }
8484
0 commit comments