@@ -57,18 +57,23 @@ export class SQLJob {
57
57
const connection = instance . getConnection ( ) ;
58
58
return new Promise ( ( resolve , reject ) => {
59
59
// Setting QIBM_JAVA_STDIO_CONVERT and QIBM_PASE_DESCRIPTOR_STDIO to make sure all PASE and Java converters are off
60
- const startingCommand = `QIBM_JAVA_STDIO_CONVERT=N QIBM_PASE_DESCRIPTOR_STDIO=B exec ` + ServerComponent . getInitCommand ( ) ;
60
+ const startingCommand = `QIBM_JAVA_STDIO_CONVERT=N QIBM_PASE_DESCRIPTOR_STDIO=B execggg ` + ServerComponent . getInitCommand ( ) ;
61
61
62
62
ServerComponent . writeOutput ( startingCommand ) ;
63
63
64
- const a = connection . client . connection . exec ( startingCommand , { } , ( err : any , stream : any , options : { encoding : `binary`} ) => {
64
+ const a = connection . client . connection . exec ( startingCommand , ( err : any , stream : any , options : { encoding : `binary`} ) => {
65
65
if ( err ) {
66
66
reject ( err ) ;
67
67
ServerComponent . writeOutput ( err ) ;
68
68
}
69
+
69
70
let outString = `` ;
70
71
71
- stream . on ( `data` , ( data : Buffer ) => {
72
+ stream . stderr . on ( `data` , ( data : Buffer ) => {
73
+ ServerComponent . writeOutput ( data . toString ( ) ) ;
74
+ } )
75
+
76
+ stream . stdout . on ( `data` , ( data : Buffer ) => {
72
77
outString += String ( data ) ;
73
78
if ( outString . endsWith ( `\n` ) ) {
74
79
let thisMsg = outString ;
@@ -111,20 +116,16 @@ export class SQLJob {
111
116
async connect ( ) : Promise < ConnectionResult > {
112
117
this . channel = await this . getChannel ( ) ;
113
118
114
- this . channel . on ( `error` , ( ) => {
119
+ this . channel . on ( `error` , ( err ) => {
120
+ ServerComponent . writeOutput ( err ) ;
115
121
this . dispose ( ) ;
116
122
} )
117
123
118
124
this . channel . on ( `close` , ( code : number ) => {
125
+ ServerComponent . writeOutput ( `Exited with code ${ code } .` )
119
126
this . dispose ( ) ;
120
-
121
- if ( code !== 0 ) {
122
- throw new Error ( `Ended with ${ code } ` ) ;
123
- }
124
127
} )
125
128
126
- this . status = JobStatus . Ready ;
127
-
128
129
const props = Object
129
130
. keys ( this . options )
130
131
. map ( prop => {
@@ -154,6 +155,10 @@ export class SQLJob {
154
155
throw new Error ( connectResult . error || `Failed to connect to server.` ) ;
155
156
}
156
157
158
+ if ( this . status === JobStatus . Ended ) {
159
+ throw new Error ( `Failed to connect properly.` ) ;
160
+ }
161
+
157
162
this . id = connectResult . job ;
158
163
this . status = JobStatus . Ready ;
159
164
0 commit comments