# Stack trace for SyntaxError hides the actual point of failure

**URL:** <https://discourse.nodered.org/t/stack-trace-for-syntaxerror-hides-the-actual-point-of-failure/50117>\
**Category:** General\
**Created:** [24 August 2021 16:05 UTC](https://discourse.nodered.org/t/stack-trace-for-syntaxerror-hides-the-actual-point-of-failure/50117 "2021-08-24T16:05:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lowlyocean](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lowlyocean/32/46547_2.png) [@lowlyocean](https://discourse.nodered.org/u/lowlyocean)\
**Post date:** [24 August 2021 16:45 UTC](https://discourse.nodered.org/t/stack-trace-for-syntaxerror-hides-the-actual-point-of-failure/50117/2 "2021-08-24T16:45:44Z")

</div>

I found [this excellent suggestion](https://discourse.nodered.org/t/how-to-get-errors-exceptions-while-developing-custom-node/23830/3) about improved error tracing when loading Nodes themselves, but it turns out that loading the Node isn't when my issue happens.

By adding the following to _logging_ section of **settings.js** like this:

```auto
        callstack: {
            level: 'error',
            metrics: false,
            handler: function(conf) {
                return function(msg) {
                    e = new Error();
                    console.error(e.stack);
// console.trace();
                }
            }
        }

```

I was able to see this (still not far enough to find the underlying problem):

```auto
24 Aug 12:38:05 - [error] [alexa-remote-account:c969cb45.22f3d8] Invalid or unexpected token
Error
  at LogHandler.handler (/var/www/.node-red/settings.js:256:25)
  at LogHandler.<anonymous> (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/log.js:66:18)
  at LogHandler.emit (events.js:400:28)
  at /usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/log.js:160:21
  at Array.forEach (<anonymous>)
  at Object.log (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/log.js:159:21)
  at Object.log (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:739:19)
  at Flow.log (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:128:21)
  at log_helper (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:498:16)
  at AlexaRemoteAccountNode.Node.error (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:527:9)

```

But combining Bart's idea with the Node.js file mentioned in this last callstack, I was finally able to see where this cryptic error is raised by adding **console.error(msg)** above [this line](https://github.com/node-red/node-red/blob/master/packages/node_modules/@node-red/runtime/lib/nodes/Node.js#L526). Would be be helpful I think to add this as well as Bart's suggestion to the master branch.

---

_[View the full topic](https://discourse.nodered.org/t/stack-trace-for-syntaxerror-hides-the-actual-point-of-failure/50117)._
