File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1523,8 +1523,12 @@ class Spanner extends GrpcService {
15231523 return ;
15241524 }
15251525 const clientName = config . client ;
1526- if ( ! this . clients_ . has ( clientName ) ) {
1527- this . clients_ . set ( clientName , new v1 [ clientName ] ( this . options ) ) ;
1526+ try {
1527+ if ( ! this . clients_ . has ( clientName ) ) {
1528+ this . clients_ . set ( clientName , new v1 [ clientName ] ( this . options ) ) ;
1529+ }
1530+ } catch ( err ) {
1531+ callback ( err , null ) ;
15281532 }
15291533 const gaxClient = this . clients_ . get ( clientName ) ! ;
15301534 let reqOpts = extend ( true , { } , config . reqOpts ) ;
Original file line number Diff line number Diff line change @@ -2000,6 +2000,22 @@ describe('Spanner', () => {
20002000 } ) ;
20012001 } ) ;
20022002
2003+ it ( 'should be able to catch any error from google-gax-library' , done => {
2004+ const error = new Error ( 'Error.' ) ;
2005+
2006+ fakeV1 [ CONFIG . client ] = class {
2007+ constructor ( options ) {
2008+ assert . strictEqual ( options , spanner . options ) ;
2009+ throw error ;
2010+ }
2011+ } ;
2012+
2013+ spanner . prepareGapicRequest_ ( CONFIG , err => {
2014+ assert . strictEqual ( err , error ) ;
2015+ done ( ) ;
2016+ } ) ;
2017+ } ) ;
2018+
20032019 it ( 'should create and cache a gapic client' , done => {
20042020 fakeV1 [ CONFIG . client ] = class {
20052021 constructor ( options ) {
You can’t perform that action at this time.
0 commit comments