Skip to content

Commit ecb27d2

Browse files
author
Marcus Boerger
authored
Improve error messages. (#494)
Improve error messages. Keep old short messages for the tests.
1 parent ed12128 commit ecb27d2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

toolchain/internal/llvm_distributions.bzl

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -947,19 +947,22 @@ def _find_llvm_basename_list(llvm_version, host_info):
947947
def _find_llvm_basename_or_error(llvm_version, host_info):
948948
basenames = _find_llvm_basename_list(llvm_version, host_info)
949949
if len(basenames) > 1:
950-
return None, "ERROR: Multiple configurations found [{basenames}].".format(
950+
return None, "ERROR: Multiple configurations found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}: [{basenames}].".format(
951+
llvm_version = llvm_version,
952+
os = host_info.os,
953+
dist_name = host_info.dist.name,
954+
dist_version = host_info.dist.version,
955+
arch = host_info.arch,
951956
basenames = ", ".join(basenames),
952957
)
953958
if not basenames:
954-
return None, "ERROR: No version selected"
955-
# TODO(helly25): Enable better error message:
956-
#"ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
957-
# llvm_version = llvm_version,
958-
# os = host_info.os,
959-
# dist_name = host_info.dist.name,
960-
# dist_version = host_info.dist.version,
961-
# arch = host_info.arch,
962-
#)
959+
return None, "ERROR: No matching config could be found for version {llvm_version} on {os}/{dist_name}/{dist_version} with arch {arch}.".format(
960+
llvm_version = llvm_version,
961+
os = host_info.os,
962+
dist_name = host_info.dist.name,
963+
dist_version = host_info.dist.version,
964+
arch = host_info.arch,
965+
)
963966

964967
# Use the following for debugging:
965968
# print("Found LLVM: " + basenames[0]) # buildifier: disable=print
@@ -977,7 +980,7 @@ def _distribution_urls(rctx):
977980
basename = rctx.attr.distribution
978981

979982
if basename not in _llvm_distributions:
980-
fail("Unknown LLVM release: %s\nPlease ensure file name is correct." % basename)
983+
fail("ERROR: Unknown LLVM release: %s\nPlease ensure file name is correct." % basename)
981984

982985
urls = []
983986
url_suffix = "{0}/{1}".format(llvm_version, basename).replace("+", "%2B")
@@ -1135,17 +1138,21 @@ def _write_distributions_impl(ctx):
11351138
_version_string(version),
11361139
host_info,
11371140
)
1138-
if not error:
1141+
if error:
1142+
if error.startswith("ERROR: No matching config could be found for version"):
1143+
# Simplify test output:
1144+
error = "ERROR: No version selected"
1145+
else:
11391146
if predicted.endswith(".exe"):
11401147
error = "ERROR: Windows .exe is not supported: " + predicted
11411148
elif predicted not in _llvm_distributions:
11421149
error = "ERROR: Unavailable prediction: " + predicted
11431150
elif len(basenames) == 0:
1144-
predicted = "ERROR: No version selected"
1151+
error = "ERROR: No version selected"
11451152
elif len(basenames) == 1:
11461153
predicted = basenames[0]
11471154
else:
1148-
predicted = "ERROR: Multiple selections"
1155+
error = "ERROR: Multiple selections"
11491156
if not error:
11501157
arch_found = [arch for arch in arch_list if arch in predicted]
11511158
if len(arch_found) == 1 and arch_found[0] != arch:

0 commit comments

Comments
 (0)