diff --git a/PyDictionary/core.py b/PyDictionary/core.py index 1eb7298..8171bad 100644 --- a/PyDictionary/core.py +++ b/PyDictionary/core.py @@ -60,7 +60,7 @@ def translate(self, term, language): word = gs.translate(term, language) return word except: - print("Invalid Word") + raise InvalidWord def getSynonyms(self, formatted=True): return [self.synonym(term, formatted) for term in self.args] @@ -97,7 +97,7 @@ def synonym(term, formatted=False): @staticmethod def antonym(term, formatted=False): if len(term.split()) > 1: - print("Error: A Term must be only a single word") + raise TooManyWords else: try: data = _get_soup_object("https://www.synonym.com/synonyms/{0}".format(term)) @@ -108,12 +108,12 @@ def antonym(term, formatted=False): return {term: antonyms} return antonyms except: - print("{0} has no Antonyms in the API".format(term)) + raise NoResults @staticmethod def meaning(term, disable_errors=False): if len(term.split()) > 1: - print("Error: A Term must be only a single word") + raise TooManyWords else: try: html = _get_soup_object("http://wordnetweb.princeton.edu/perl/webwn?s={0}".format( @@ -135,7 +135,7 @@ def meaning(term, disable_errors=False): return out except Exception as e: if disable_errors == False: - print("Error: The Following Error occured: %s" % e) + raise e if __name__ == '__main__': d = PyDictionary('honest','happy')