@sasjs/core 5.2.2 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -41,5 +41,5 @@
41
41
  "maintainers": [
42
42
  "https://sasapps.io"
43
43
  ],
44
- "version": "5.2.2"
44
+ "version": "5.2.3"
45
45
  }
@@ -84,6 +84,7 @@
84
84
 
85
85
  <h4> SAS Macros </h4>
86
86
  @li mp_abort.sas
87
+ @li mf_existvar.sas
87
88
  @li mf_getplatform.sas
88
89
  @li mf_existfileref.sas
89
90
  @li mf_getuniquefileref.sas
@@ -96,7 +97,8 @@
96
97
  ,grant_type=sas_services
97
98
  ,mdebug=0
98
99
  );
99
- %local dbg libref1 libref2 loglocation fname1 fname2;
100
+ %local dbg libref1 libref2 loglocation fname1 fname2 jobstate err_httpcode
101
+ err_msg abortmsg;
100
102
  %if &mdebug=1 %then %do;
101
103
  %put &sysmacroname entry vars:;
102
104
  %put _local_;
@@ -182,7 +184,49 @@ libname &libref1 JSON fileref=&fname1;
182
184
  data _null_;
183
185
  set &libref1..root;
184
186
  call symputx('loglocation',loglocation,'l');
187
+ %if %mf_existvar(&libref1..root,state) %then %do;
188
+ call symputx('jobstate',state,'l');
189
+ %end;
190
+ %else %do;
191
+ call symputx('jobstate','unknown','l');
192
+ %end;
185
193
  run;
194
+ /* If root had zero observations, jobstate was never set - fall back to
195
+ "unknown" so the abort message below reads cleanly. */
196
+ %if %str(&jobstate)= %then %let jobstate=unknown;
197
+
198
+ /* A real loglocation is always a /files/files/<uuid> URI (48+ chars), so
199
+ length<2 unambiguously means the job has no log (empty or SAS missing
200
+ value) - the job likely failed before a compute session was created
201
+ (e.g. 403 on session creation). Read the error details from the job
202
+ response so the actual failure reason is reported instead of the
203
+ opaque "URI is too short" message. */
204
+ %if &mdebug=1 %then %do;
205
+ %put &sysmacroname: jobstate=[&jobstate] loglocation=[&loglocation];
206
+ %end;
207
+ %if %length(&loglocation)<2 %then %do;
208
+ %let err_httpcode=;
209
+ %let err_msg=;
210
+ %if %sysfunc(exist(&libref1..error)) %then %do;
211
+ data _null_;
212
+ set &libref1..error;
213
+ call symputx('err_httpcode',httpStatusCode,'l');
214
+ call symputx('err_msg',message,'l');
215
+ putlog "&sysmacroname: Job &jobstate - error " httpStatusCode ": " message;
216
+ stop;
217
+ run;
218
+ %end;
219
+ /* Build the abort message so it reads cleanly whether or not error
220
+ details were available (err_msg stays empty if the table is absent
221
+ or has zero observations). Include the job URI so the full JSON
222
+ response can be fetched directly via a GET to &base_uri&uri. */
223
+ %let abortmsg=Job &jobstate, no log available. GET &uri;
224
+ %if %length(&err_msg)>0 %then %let abortmsg=Job &jobstate, no log available. Error &err_httpcode: &err_msg. GET &uri;
225
+ %mp_abort(iftrue=(1=1)
226
+ ,mac=&sysmacroname
227
+ ,msg=%str(&abortmsg)
228
+ )
229
+ %end;
186
230
 
187
231
  /* validate log path*/
188
232
  %let errflg=1;
@@ -273,7 +273,7 @@ data;run;%let jdswaitfor=&syslast;
273
273
  %let _vnm=%scan(&cvars,&ii,%str( ));
274
274
  if _param ne '' then _param=cats(_param,',');
275
275
  _param=cats(_param,'"'
276
- ,"%lowcase(&_vnm)"
276
+ ,"&_vnm"
277
277
  ,'":'
278
278
  ,quote(trim(&_vnm))
279
279
  );
@@ -282,7 +282,7 @@ data;run;%let jdswaitfor=&syslast;
282
282
  %let _vnm=%scan(&nvars,&ii,%str( ));
283
283
  if _param ne '' then _param=cats(_param,',');
284
284
  _param=cats(_param,'"'
285
- ,"%lowcase(&_vnm)"
285
+ ,"&_vnm"
286
286
  ,'":"'
287
287
  ,strip(put(&_vnm,best32.))
288
288
  ,'"'