Skip to content

Conversation

@KristjanESPERANTO
Copy link
Collaborator

@KristjanESPERANTO KristjanESPERANTO commented Oct 22, 2025

  • Combine file existence and permission checks with better error messages
  • Replace thrown exceptions with clean error output (no stack traces)
  • Support custom module positions by changing strict validation to warnings
  • Add missing process.exit(1) after validation errors

Users now see clear, actionable error messages without stack traces, and custom region configurations work correctly.

example before

$ npm run start

> [email protected] start
> node --run start:x11

[2025-10-22 17:56:06.303] [LOG]   Starting MagicMirror: v2.34.0-develop 
[2025-10-22 17:56:06.304] [LOG]   Loading config ... 
[2025-10-22 17:56:06.304] [LOG]   config template file not exists, no envsubst 
[2025-10-22 17:56:06.356] [ERROR] File not found: /home/kristjan/MagicMirror/config/config.js
No config file present! 
[2025-10-22 17:56:06.356] [ERROR] [checkconfig] Error: Error: ENOENT: no such file or directory, access '/home/kristjan/MagicMirror/config/config.js'
No permission to access config file!
    at checkConfigFile (/home/kristjan/MagicMirror/js/check_config.js:43:9)
    at Object.<anonymous> (/home/kristjan/MagicMirror/js/check_config.js:138:2)
    at Module._compile (node:internal/modules/cjs/loader:1714:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1848:10)
    at Module.load (node:internal/modules/cjs/loader:1448:32)
    at Module._load (node:internal/modules/cjs/loader:1270:12)
    at c._load (node:electron/js2c/node_init:2:17993)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
    at Module.require (node:internal/modules/cjs/loader:1470:12)
    at require (node:internal/modules/helpers:147:16)
    at loadConfig (/home/kristjan/MagicMirror/js/app.js:126:3)
    at App.start (/home/kristjan/MagicMirror/js/app.js:291:18)
    at Object.<anonymous> (/home/kristjan/MagicMirror/js/electron.js:228:7)
    at Module._compile (node:internal/modules/cjs/loader:1714:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1848:10) 

example after

$ npm run start

> [email protected] start
> node --run start:x11

[2025-10-22 21:33:27.930] [LOG]   Starting MagicMirror: v2.34.0-develop 
[2025-10-22 21:33:27.931] [LOG]   Loading config ... 
[2025-10-22 21:33:27.931] [LOG]   config template file not exists, no envsubst 
[2025-10-22 21:33:27.985] [ERROR] [check_config] File not found: /home/kristjan/MagicMirror/config/config.js 

@KristjanESPERANTO KristjanESPERANTO marked this pull request as draft October 22, 2025 19:47
@rejas
Copy link
Collaborator

rejas commented Oct 22, 2025

Users now see clearer, actionable error messages instead of unnecessary technical output (stack trace) when their config file has issues.

nice pr, but could we have an option that enables the stacktraces again (so one can still get them when needed)

maybe a command line param to enable it, since if it was a config.js option it might not work when check_config fails for some reason (since the config wouldnt have been loaded)

- Combine file existence and permission checks with better error messages
- Replace thrown exceptions with clean error output (no stack traces)
- Support custom module positions by changing strict validation to warnings
- Add consistent [check_config] prefix to all log messages
- Add missing process.exit(1) after validation errors

Users now see clear, actionable error messages without stack traces, and
custom region configurations work correctly.
@KristjanESPERANTO KristjanESPERANTO changed the title [check_config] refactor: improve error handling and user experience [check_config] refactor: improve error handling Oct 22, 2025
@KristjanESPERANTO
Copy link
Collaborator Author

nice pr, but could we have an option that enables the stacktraces again (so one can still get them when needed)

The stack traces are only removed for 'expected' validation errors (file not found, syntax error, invalid position) - with showing clean error messages there is no need of the stack trace, I think. The stack traces weren't providing useful debugging information, they just showed where we intentionally check for these errors.

For unexpected errors, there will be stack traces also after this change (the catch block at the bottom still logs them).

Should I nevertheless add a parameter?

@KristjanESPERANTO KristjanESPERANTO marked this pull request as ready for review October 22, 2025 21:30
@rejas rejas merged commit 9ad5618 into MagicMirrorOrg:develop Oct 23, 2025
9 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the config branch October 26, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants