« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/checks.js9
-rw-r--r--src/data/thing.js21
2 files changed, 23 insertions, 7 deletions
diff --git a/src/data/checks.js b/src/data/checks.js
index 88dfbc6d..fcafbaca 100644
--- a/src/data/checks.js
+++ b/src/data/checks.js
@@ -568,7 +568,16 @@ export function filterReferenceErrors(wikiData, {
                 break;
 
               default:
+                if (findFnKey.startsWith('_')) {
+                  throw new Error(`Unknown specially handled find function "${findFnKey}"`);
+                }
+
                 findFn = boundFind[findFnKey];
+
+                if (!findFn) {
+                  throw new Error(`Unknown find function "${findFnKey}"`);
+                }
+
                 break;
             }
 
diff --git a/src/data/thing.js b/src/data/thing.js
index f5afe076..621dff5a 100644
--- a/src/data/thing.js
+++ b/src/data/thing.js
@@ -67,7 +67,11 @@ export default class Thing extends CacheableObject {
       name = colors.yellow(`couldn't get name`);
     }
 
-    let reference = Thing.inspectReference(this, {showConstructor: false});
+    let reference =
+      Thing.inspectReference(this, {
+        showConstructor: false,
+        showName: false,
+      });
 
     return (
       (name ? `${constructorName} ${name}` : `${constructorName}`) +
@@ -120,7 +124,10 @@ export default class Thing extends CacheableObject {
     return `${thing.constructor[Thing.referenceType]}:${thing.directory}`;
   }
 
-  static inspectReference(thing, {showConstructor = true} = {}) {
+  static inspectReference(thing, {
+    showConstructor = true,
+    showName = true,
+  } = {}) {
     const referenceType =
       thing.constructor[Thing.referenceType] ??
       null;
@@ -145,12 +152,12 @@ export default class Thing extends CacheableObject {
 
     if (directoryPart && referenceType) {
       return colors.blue(`${referenceType}:${directoryPart}`);
-    } else if (directoryPart) {
-      return constructorPart + `(${colors.blue(directoryPart)})`;
-    } else if (tryToGet('name')) {
-      return constructorPart + `(named ${inspect(thing.name)}`;
+    } if (directoryPart) {
+      return constructorPart + `${colors.blue(directoryPart)}`;
+    } else if (showName && tryToGet('name')) {
+      return constructorPart + `named ${inspect(thing.name)}`;
     } else if (errored && directoryErrored) {
-      return constructorPart + `(${colors.yellow(`couldn't compute reference`)})`;
+      return constructorPart + `${colors.yellow(`couldn't compute reference`)}`;
     } else {
       return constructorPart;
     }