@@ -5,6 +5,7 @@ import { RunQuery } from '../lib/connectionPool'
5
5
import { DEFAULT_SYSTEM_SCHEMAS } from '../lib/constants'
6
6
import { Tables } from '../lib/interfaces'
7
7
import sqlTemplates = require( '../lib/sql' )
8
+ import { logger } from '../lib/logger'
8
9
9
10
/**
10
11
* @param {string } [include_system_schemas=false] - Return system schemas as well as user schemas
@@ -25,7 +26,7 @@ router.get('/', async (req, res) => {
25
26
if ( ! include_system_schemas ) payload = removeSystemSchemas ( data )
26
27
return res . status ( 200 ) . json ( payload )
27
28
} catch ( error ) {
28
- console . log ( 'throwing error' , error )
29
+ logger . error ( { error, req : req . body } )
29
30
res . status ( 500 ) . json ( { error : error . message } )
30
31
}
31
32
} )
@@ -46,8 +47,7 @@ router.post('/', async (req, res) => {
46
47
const newPolicy = await getPolicyByName ( pcConnection , name , schema , table )
47
48
return res . status ( 200 ) . json ( newPolicy )
48
49
} catch ( error ) {
49
- // For this one, we always want to give back the error to the customer
50
- console . log ( 'POST error!' , error )
50
+ logger . error ( { error, req : req . body } )
51
51
res . status ( 400 ) . json ( { error : error . message } )
52
52
}
53
53
} )
@@ -83,8 +83,7 @@ router.patch('/:id', async (req, res) => {
83
83
const updated = await getPolicyById ( pcConnection , id )
84
84
return res . status ( 200 ) . json ( updated )
85
85
} catch ( error ) {
86
- // For this one, we always want to give back the error to the customer
87
- console . log ( 'Soft error!' , error )
86
+ logger . error ( { error, req : req . body } )
88
87
res . status ( 400 ) . json ( { error : error . message } )
89
88
}
90
89
} )
@@ -105,7 +104,7 @@ router.delete('/:id', async (req, res) => {
105
104
106
105
return res . status ( 200 ) . json ( policy )
107
106
} catch ( error ) {
108
- console . log ( 'throwing error' , error )
107
+ logger . error ( { error, req : req . body } )
109
108
res . status ( 400 ) . json ( { error : error . message } )
110
109
}
111
110
} )
0 commit comments