File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,18 @@ function ConManager(baseurl, token_name) {
113113 resp += chunk ;
114114 } ) ;
115115 res . on ( 'end' , ( ) => {
116- if ( resp )
117- resp = JSON . parse ( resp ) ;
116+ if ( resp ) {
117+ try {
118+ resp = JSON . parse ( resp ) ;
119+ } catch ( e ) {
120+ if ( e instanceof SyntaxError ) {
121+ resp = { 'httpErrorCode' : res . statusCode , 'code' : res . statusMessage , 'description' : resp } ;
122+ res . statusCode = 500 ;
123+ } else {
124+ throw e ;
125+ }
126+ }
127+ }
118128
119129 debug ( resp ) ;
120130 debug ( "==================================================" ) ;
@@ -136,8 +146,18 @@ function ConManager(baseurl, token_name) {
136146 nresp += chunk ;
137147 } ) ;
138148 nres . on ( 'end' , ( ) => {
139- if ( nresp )
140- nresp = JSON . parse ( nresp ) ;
149+ if ( nresp ) {
150+ try {
151+ nresp = JSON . parse ( nresp ) ;
152+ } catch ( e ) {
153+ if ( e instanceof SyntaxError ) {
154+ nresp = { 'httpErrorCode' : nres . statusCode , 'code' : nres . statusMessage , 'description' : nresp } ;
155+ nres . statusCode = 500 ;
156+ } else {
157+ throw e ;
158+ }
159+ }
160+ }
141161
142162 debug ( nresp ) ;
143163 debug ( "==================================================" ) ;
@@ -504,6 +524,6 @@ function ConManager(baseurl, token_name) {
504524 */
505525
506526 this . login_response = { } ;
507- } ;
527+ }
508528
509529exports . ConManager = ConManager ;
You can’t perform that action at this time.
0 commit comments