« get me outta code hell

write: live-dev-server: output full error traces - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-08 22:34:11 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-28 17:14:15 -0400
commitdc8cc7f42d1d7f6d87252da13b15b177317f362f (patch)
treed9e064495f3852c52a75347365a6608011b85fa0 /src
parent7b77a1d8cafeb25d6f9c7e8a0c93f4aae0cc049b (diff)
write: live-dev-server: output full error traces
Diffstat (limited to 'src')
-rw-r--r--src/write/build-modes/live-dev-server.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js
index b0272809..e2c976b9 100644
--- a/src/write/build-modes/live-dev-server.js
+++ b/src/write/build-modes/live-dev-server.js
@@ -2,8 +2,9 @@ import {spawn} from 'node:child_process';
 import * as http from 'node:http';
 import {readFile, stat} from 'node:fs/promises';
 import * as path from 'node:path';
+import {inspect as nodeInspect} from 'node:util';
 
-import {logInfo, logWarn, progressCallAll} from '#cli';
+import {ENABLE_COLOR, logInfo, logWarn, progressCallAll} from '#cli';
 import {watchContentDependencies} from '#content-dependencies';
 import {quickEvaluate} from '#content-function';
 import * as html from '#html';
@@ -24,6 +25,10 @@ const defaultPort = 8002;
 
 export const description = `Hosts a local HTTP server which generates page content as it is requested, instead of all at once; reacts to changes in data files, so new reloads will be up-to-date with on-disk YAML data (<- not implemented yet, check back soon!)\n\nIntended for local development ONLY; this custom HTTP server is NOT rigorously tested and almost certainly has security flaws`;
 
+function inspect(value, opts = {}) {
+  return nodeInspect(value, {colors: ENABLE_COLOR, ...opts});
+}
+
 export function getCLIOptions() {
   return {
     host: {
@@ -82,7 +87,7 @@ export async function go({
     if (error instanceof AggregateError && niceShowAggregate) {
       niceShowAggregate(error);
     } else {
-      console.error(error);
+      console.error(inspect(error, {depth: Infinity}));
     }
   };