diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-07-15 10:51:54 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:03 +0000 |
commit | 9fede3c6fd43bd6c715c50c5c511de519416e9c4 (patch) | |
tree | 8c17ad9c3a45b7f7dd012408d9ae59a9bd6158a9 | |
parent | ee642d79724495343521949f1268b9a7068c267f (diff) | |
download | buildstream-9fede3c6fd43bd6c715c50c5c511de519416e9c4.tar.gz |
node: Make error messages more user-friendly
Users should not have to know anything about nodes, and should be
greeted by commonly defined yaml types.
-rw-r--r-- | src/buildstream/node.pyx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/buildstream/node.pyx b/src/buildstream/node.pyx index 5c4db051b..53cbc28d3 100644 --- a/src/buildstream/node.pyx +++ b/src/buildstream/node.pyx @@ -298,7 +298,7 @@ cdef class MappingNode(Node): if type(value) is not MappingNode and value is not None: provenance = value.get_provenance() raise LoadError(LoadErrorReason.INVALID_DATA, - "{}: Value of '{}' is not of the expected type 'Mapping'" + "{}: Value of '{}' is not of the expected type 'dict'" .format(provenance, key)) return value @@ -316,9 +316,17 @@ cdef class MappingNode(Node): if allowed_types and type(value) not in allowed_types: provenance = self.get_provenance() + human_types = [] + if MappingNode in allowed_types: + human_types.append("dict") + if SequenceNode in allowed_types: + human_types.append('list') + if ScalarNode in allowed_types: + human_types.append('scalar') + raise LoadError(LoadErrorReason.INVALID_DATA, "{}: Value of '{}' is not one of the following: {}.".format( - provenance, key, ", ".join(allowed_types))) + provenance, key, ", ".join(human_types))) return value @@ -331,7 +339,7 @@ cdef class MappingNode(Node): else: provenance = value.get_provenance() raise LoadError(LoadErrorReason.INVALID_DATA, - "{}: Value of '{}' is not of the expected type 'Scalar'" + "{}: Value of '{}' is not of the expected type 'scalar'" .format(provenance, key)) return value @@ -342,7 +350,7 @@ cdef class MappingNode(Node): if type(value) is not SequenceNode and value is not None: provenance = value.get_provenance() raise LoadError(LoadErrorReason.INVALID_DATA, - "{}: Value of '{}' is not of the expected type 'Sequence'" + "{}: Value of '{}' is not of the expected type 'list'" .format(provenance, key)) return value |