@@ -2,7 +2,7 @@ import { FastifyInstance, FastifyRequest } from 'fastify'
2
2
import { PostgresMeta } from '../../lib'
3
3
import * as Parser from '../../lib/Parser'
4
4
import { DEFAULT_POOL_CONFIG } from '../constants'
5
- import { extractRequestForLogging } from '../utils'
5
+ import { extractRequestForLogging , translateErrorToResponseCode } from '../utils'
6
6
7
7
const errorOnEmptyQuery = ( request : FastifyRequest ) => {
8
8
if ( ! ( request . body as any ) . query ) {
@@ -25,7 +25,7 @@ export default async (fastify: FastifyInstance) => {
25
25
await pgMeta . end ( )
26
26
if ( error ) {
27
27
request . log . error ( { error, request : extractRequestForLogging ( request ) } )
28
- reply . code ( 400 )
28
+ reply . code ( translateErrorToResponseCode ( error ) )
29
29
return { error : error . message }
30
30
}
31
31
@@ -43,7 +43,7 @@ export default async (fastify: FastifyInstance) => {
43
43
44
44
if ( error ) {
45
45
request . log . error ( { error, request : extractRequestForLogging ( request ) } )
46
- reply . code ( 400 )
46
+ reply . code ( translateErrorToResponseCode ( error ) )
47
47
return { error : error . message }
48
48
}
49
49
@@ -61,7 +61,7 @@ export default async (fastify: FastifyInstance) => {
61
61
62
62
if ( error ) {
63
63
request . log . error ( { error, request : extractRequestForLogging ( request ) } )
64
- reply . code ( 400 )
64
+ reply . code ( translateErrorToResponseCode ( error ) )
65
65
return { error : error . message }
66
66
}
67
67
@@ -78,7 +78,7 @@ export default async (fastify: FastifyInstance) => {
78
78
79
79
if ( error ) {
80
80
request . log . error ( { error, request : extractRequestForLogging ( request ) } )
81
- reply . code ( 400 )
81
+ reply . code ( translateErrorToResponseCode ( error ) )
82
82
return { error : error . message }
83
83
}
84
84
0 commit comments