Skip to content

Commit 7c5879f

Browse files
committed
Simplified code and display detail error for template error
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 51bc39a commit 7c5879f

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/attributecode/cmd.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -324,29 +324,25 @@ def attrib(location, output, template, mapping, inventory, quiet, show_all,
324324
inventory_location=inventory)
325325

326326
# Check for template error
327-
template_error = False
328327
with open(output, 'r') as output_file:
329328
first_line = output_file.readline()
330329
if first_line.startswith('Template processing error'):
331-
template_error = True
330+
click.echo(first_line)
331+
sys.exit(errno.ENOEXEC)
332332

333-
if template_error:
334-
click.echo('Template processing error. Please check the template.')
335-
sys.exit(errno.ENOEXEC)
333+
for no_match_error in no_match_errors:
334+
inv_errors.append(no_match_error)
335+
336+
finalized_errors = []
337+
338+
if not validate_about_resource:
339+
finalized_errors = ignore_about_resource_path_error(inv_errors)
336340
else:
337-
for no_match_error in no_match_errors:
338-
inv_errors.append(no_match_error)
339-
340-
finalized_errors = []
341-
342-
if not validate_about_resource:
343-
finalized_errors = ignore_about_resource_path_error(inv_errors)
344-
else:
345-
finalized_errors = inv_errors
346-
347-
log_errors(finalized_errors, quiet, show_all, os.path.dirname(output))
348-
click.echo('Finished.')
349-
sys.exit(0)
341+
finalized_errors = inv_errors
342+
343+
log_errors(finalized_errors, quiet, show_all, os.path.dirname(output))
344+
click.echo('Finished.')
345+
sys.exit(0)
350346

351347

352348
######################################################################

0 commit comments

Comments
 (0)