From cacdd2cc83c5086abdffa137e8c6367bed2e8e3b Mon Sep 17 00:00:00 2001 From: "Curtis M. Humphrey, Ph.D" Date: Wed, 8 Mar 2017 19:23:24 -0600 Subject: [PATCH 1/2] added more information to error messages --- src/getClassName.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/getClassName.js b/src/getClassName.js index 2b5b53f..2db350e 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -22,11 +22,11 @@ const getClassNameForNamespacedStyleName = (styleName: string, styleModuleImport } if (!styleModuleImportMap[importName]) { - throw new Error('CSS module import does not exist.'); + throw new Error('CSS module import,' + importName + ', does not exist.'); } if (!styleModuleImportMap[importName][moduleName]) { - throw new Error('CSS module does not exist.'); + throw new Error('CSS module,' + moduleName + ', does not exist in import, ' + importName + '.'); } return styleModuleImportMap[importName][moduleName]; From ea426f440544816fd7b0d4b4c84087e77e0c4999 Mon Sep 17 00:00:00 2001 From: Gajus Kuizinas Date: Thu, 9 Mar 2017 08:22:54 +0000 Subject: [PATCH 2/2] feat: use console.log to provide additional debugging information --- src/getClassName.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/getClassName.js b/src/getClassName.js index 2db350e..5626bf3 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -18,15 +18,31 @@ const getClassNameForNamespacedStyleName = (styleName: string, styleModuleImport const moduleName = styleNameParts[1]; if (!moduleName) { + // eslint-disable-next-line no-console + console.log({ + moduleName + }); + throw new Error('Invalid style name.'); } if (!styleModuleImportMap[importName]) { - throw new Error('CSS module import,' + importName + ', does not exist.'); + // eslint-disable-next-line no-console + console.log({ + importName + }); + + throw new Error('CSS module import does not exist.'); } if (!styleModuleImportMap[importName][moduleName]) { - throw new Error('CSS module,' + moduleName + ', does not exist in import, ' + importName + '.'); + // eslint-disable-next-line no-console + console.log({ + importName, + moduleName + }); + + throw new Error('CSS module does not exist.'); } return styleModuleImportMap[importName][moduleName]; @@ -56,7 +72,12 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM const styleModuleMap: StyleModuleMapType = styleModuleImportMap[styleModuleImportMapKeys[0]]; if (!styleModuleMap[styleName]) { - throw new Error('Could not resolve the styleName \'' + styleName + '\'.'); + // eslint-disable-next-line no-console + console.log({ + styleName + }); + + throw new Error('Could not resolve a styleName.'); } return styleModuleMap[styleName];