@@ -24,7 +24,7 @@ module.exports = async(
24
24
{ log = ( ) => { } }
25
25
) => {
26
26
const { link : { gluePrefix = '.' , schemas : sc } = { } } = config ;
27
- const schemas = sc instanceof Array ? sc : [ sc ] ;
27
+ const schemas = Array . isArray ( sc ) ? sc : [ sc ] ;
28
28
const link = await connectionPool ( log ) (
29
29
config . connection ,
30
30
{ log}
@@ -117,13 +117,13 @@ module.exports = async(
117
117
...methods ,
118
118
/**
119
119
* Description
120
- * @param {Object } arguments
120
+ * @param {Object } args
121
121
* @param {number } txId
122
122
* @returns {any }
123
123
*/
124
- [ jsName ] : async ( arguments = { } , txId ) => {
124
+ [ jsName ] : async ( args = { } , txId ) => {
125
125
const dynArgs = args . input . map ( ( { name} ) => {
126
- if ( arguments [ name ] === undefined ) {
126
+ if ( args [ name ] === undefined ) {
127
127
if ( oArgNames [ name ] !== undefined ) {
128
128
return oArgNames [ name ] ;
129
129
}
@@ -132,7 +132,7 @@ module.exports = async(
132
132
{ fn : jsName , argument : name }
133
133
) ;
134
134
}
135
- return arguments [ name ] ;
135
+ return args [ name ] ;
136
136
} ) ;
137
137
try {
138
138
if ( ! txId ) {
@@ -165,11 +165,16 @@ module.exports = async(
165
165
* @returns {number }
166
166
*/
167
167
async txBegin ( ) {
168
- const id = ++ txId ;
169
- const client = await link . connect ( ) ;
170
- await client . query ( 'BEGIN' ) ;
171
- txMap . set ( id , client ) ;
172
- return id ;
168
+ try {
169
+ const id = ++ txId ;
170
+ const client = await link . connect ( ) ;
171
+ await client . query ( 'BEGIN' ) ;
172
+ txMap . set ( id , client ) ;
173
+ return id ;
174
+ } catch ( e ) {
175
+ log ( 'error' , `TX Begin: id: ${ id } ` , e ) ;
176
+ throw e ;
177
+ }
173
178
} ,
174
179
/**
175
180
* Description
@@ -178,10 +183,15 @@ module.exports = async(
178
183
* @returns {void }
179
184
*/
180
185
async txEnd ( id , action ) {
181
- const client = txMap . get ( id ) ;
182
- await client . query ( action ) ;
183
- client . release ( ) ;
184
- txMap . delete ( id ) ;
186
+ try {
187
+ const client = txMap . get ( id ) ;
188
+ await client . query ( action ) ;
189
+ client . release ( ) ;
190
+ txMap . delete ( id ) ;
191
+ } catch ( e ) {
192
+ log ( 'error' , `TX End: id: ${ id } ` , e ) ;
193
+ throw e ;
194
+ }
185
195
}
186
196
} ;
187
197
} ;
0 commit comments