Index: graphspell-js/spellchecker.js ================================================================== --- graphspell-js/spellchecker.js +++ graphspell-js/spellchecker.js @@ -49,14 +49,15 @@ } else { return new IBDAWG(dictionary, sPath); // dictionary can be a filename or a JSON object } } catch (e) { - console.log(e.message); if (bNecessary) { - throw e.message; + throw "Error: <" + sfDictionary + "> not loaded. " + e.message; } + console.log("Error: <" + sfDictionary + "> not loaded.") + console.log(e.message); return null; } } setMainDictionary (dictionary) { Index: graphspell/spellchecker.py ================================================================== --- graphspell/spellchecker.py +++ graphspell/spellchecker.py @@ -24,21 +24,23 @@ def __init__ (self, sLangCode, sfMainDic="", sfExtendedDic="", sfPersonalDic=""): "returns True if the main dictionary is loaded" self.sLangCode = sLangCode if not sfMainDic: sfMainDic = dDefaultDictionaries.get(sLangCode, "") - self.oMainDic = self._loadDictionary(sfMainDic) + self.oMainDic = self._loadDictionary(sfMainDic, True) self.oExtendedDic = self._loadDictionary(sfExtendedDic) self.oPersonalDic = self._loadDictionary(sfPersonalDic) - def _loadDictionary (self, sfDictionary): + def _loadDictionary (self, sfDictionary, bNecessary=False): "returns an IBDAWG object" if not sfDictionary: return None try: return ibdawg.IBDAWG(sfDictionary) - except: + except Exception as e: + if bNecessary: + raise Exception(str(e), "Error: <" + sfDictionary + "> not loaded.") print("Error: <" + sfDictionary + "> not loaded.") traceback.print_exc() return None def setMainDictionary (self, sfDictionary):