@@ -1393,6 +1393,8 @@ extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid,
13931393 char * * err_msg )
13941394{
13951395 int rc ;
1396+ char * err_str = NULL ;
1397+
13961398 slurm_mutex_lock (& lua_lock );
13971399
13981400 rc = slurm_lua_loadscript (& L , "job_submit/lua" ,
@@ -1419,9 +1421,18 @@ extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid,
14191421 lua_pushnumber (L , submit_uid );
14201422 slurm_lua_stack_dump (
14211423 "job_submit/lua" , "job_submit, before lua_pcall" , L );
1422- if (lua_pcall (L , 3 , 1 , 0 ) != 0 ) {
1424+ if ((rc = slurm_lua_pcall (L , 3 , 1 , & err_str , __func__ ))) {
1425+ if (!err_str )
1426+ err_str = xstrdup_printf ("Lua %s failed: %s" ,
1427+ lua_script_path ,
1428+ slurm_strerror (rc ));
1429+
14231430 error ("%s/lua: %s: %s" ,
1424- __func__ , lua_script_path , lua_tostring (L , -1 ));
1431+ __func__ , lua_script_path , err_str );
1432+
1433+ /* Replace user_msg as err_msg with Lua error */
1434+ xfree (user_msg );
1435+ SWAP (* err_msg , err_str );
14251436 } else {
14261437 if (lua_isnumber (L , -1 )) {
14271438 rc = lua_tonumber (L , -1 );
@@ -1440,6 +1451,8 @@ extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid,
14401451 }
14411452
14421453out : slurm_mutex_unlock (& lua_lock );
1454+
1455+ xfree (err_str );
14431456 return rc ;
14441457}
14451458
@@ -1448,6 +1461,8 @@ extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
14481461 uint32_t submit_uid , char * * err_msg )
14491462{
14501463 int rc ;
1464+ char * err_str = NULL ;
1465+
14511466 slurm_mutex_lock (& lua_lock );
14521467
14531468 rc = slurm_lua_loadscript (& L , "job_submit/lua" ,
@@ -1475,9 +1490,18 @@ extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
14751490 lua_pushnumber (L , submit_uid );
14761491 slurm_lua_stack_dump (
14771492 "job_submit/lua" , "job_modify, before lua_pcall" , L );
1478- if (lua_pcall (L , 4 , 1 , 0 ) != 0 ) {
1493+ if ((rc = slurm_lua_pcall (L , 4 , 1 , & err_str , __func__ ))) {
1494+ if (!err_str )
1495+ err_str = xstrdup_printf ("Lua %s failed: %s" ,
1496+ lua_script_path ,
1497+ slurm_strerror (rc ));
1498+
14791499 error ("%s/lua: %s: %s" ,
1480- __func__ , lua_script_path , lua_tostring (L , -1 ));
1500+ __func__ , lua_script_path , err_str );
1501+
1502+ /* Replace user_msg as err_msg with Lua error */
1503+ xfree (user_msg );
1504+ SWAP (* err_msg , err_str );
14811505 } else {
14821506 if (lua_isnumber (L , -1 )) {
14831507 rc = lua_tonumber (L , -1 );
@@ -1496,5 +1520,7 @@ extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
14961520 }
14971521
14981522out : slurm_mutex_unlock (& lua_lock );
1523+
1524+ xfree (err_str );
14991525 return rc ;
15001526}
0 commit comments