Skip to content

Commit 321ac4c

Browse files
BigCat20196msyyc
andauthored
[Packaging Tools] Fix the error info is not displayed(Do not Merge) (Azure#23605)
* test * test * test * test * test * test * test * test * test * Update autorest_tools.py * Update autorest_tools.py * test * test * test * Update autorest_tools.py Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
1 parent 77a8fd6 commit 321ac4c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tools/azure-sdk-tools/packaging_tools/swaggertosdk/autorest_tools.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def generate_code(input_file, global_conf, local_conf, output_dir=None, autorest
122122

123123

124124
def execute_simple_command(cmd_line, cwd=None, shell=False, env=None):
125-
try:
125+
def run_command():
126126
process = subprocess.Popen(
127127
cmd_line,
128128
stderr=subprocess.STDOUT,
@@ -140,14 +140,16 @@ def execute_simple_command(cmd_line, cwd=None, shell=False, env=None):
140140
process.wait()
141141
output = "\n".join(output_buffer)
142142
if process.returncode:
143-
# print necessary error info
144-
for i in range(-min(len(output_buffer), 5), 0):
143+
# print necessary error info which will be displayed in swagger pr
144+
for i in range(-min(len(output_buffer), 7), 0):
145145
print(f"[Autorest] {output_buffer[i]}")
146-
147146
raise subprocess.CalledProcessError(process.returncode, cmd_line, output)
148147
return output
148+
try:
149+
return run_command()
150+
except subprocess.CalledProcessError as ex:
151+
# rerun to ensure the log contains error info
152+
return run_command()
149153
except Exception as err:
150154
_LOGGER.error(err)
151155
raise
152-
else:
153-
_LOGGER.info("Return code: %s", process.returncode)

0 commit comments

Comments
 (0)