From ba22111ff407c3e6ea462626323c9048a3d9a4e4 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Tue, 28 Jul 2020 16:24:14 +0200 Subject: [PATCH] Move error to Errors --- spacy/errors.py | 1 + spacy/util.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/errors.py b/spacy/errors.py index 862cc71d8..a10e5d9bd 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -483,6 +483,7 @@ class Errors: E199 = ("Unable to merge 0-length span at doc[{start}:{end}].") # TODO: fix numbering after merging develop into master + E952 = ("The section '{name}' is not a valid section in the provided config.") E953 = ("Mismatched IDs received by the Tok2Vec listener: {id1} vs. {id2}") E954 = ("The Tok2Vec listener did not receive a valid input.") E955 = ("Can't find table '{table}' for language '{lang}' in spacy-lookups-data.") diff --git a/spacy/util.py b/spacy/util.py index eba60795a..d1951145f 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -1121,9 +1121,8 @@ def dot_to_object(config: Config, section: str): for item in parts: try: component = component[item] - except (KeyError, TypeError) as e: - msg = f"The section '{section}' is not a valid section in the provided config." - raise KeyError(msg) + except (KeyError, TypeError): + raise KeyError(Errors.E952.format(name=section)) return component