How to get line number and column number where error has occured?

426 views
Skip to first unread message

Nithin B

unread,
Apr 12, 2018, 3:01:11 AM4/12/18
to Node-RED
Hi,

I have many function nodes that have custom logic's in them to process data.

These functions are bit long about 50 to 100 lines. Now its a big pain for me to debug the code.

Now I have 2 big head aches with this approach:

1. I cant debug my code. Is there any tool or module that I can use debug the code(I mean line by line not like using debug node)?
2. When any error occurs node-red doesn't help me giving the line and column number of the code. Is there any way to get the line number at-least?

Error will be just displayed like this:

"TypeError: Cannot set property 'l' of null"

SURPRISE: For couple of times I saw it displayed line number and column number
But unfortunately I didn't take backup of code to check what made it to display line number and column number.

Is there any format that I should follow while coding to get line and column number?

With regards,
Nithin B.

Nick O'Leary

unread,
Apr 12, 2018, 3:09:20 AM4/12/18
to node...@googlegroups.com
For syntax errors that can be spotted before running the code, we get position details from the editor widgets linter.

If you hit a runtime error with the code, the VM module we use to run it does not provide us with any position information so we aren't able to be anymore helpful with the error message.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/4deb64c6-c378-4835-ae20-597ec7b14002%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Apr 12, 2018, 3:41:37 AM4/12/18
to node...@googlegroups.com
One simple technique for debugging is to sprinkle node.warn() messages
about. That helps to find where it is going wrong.

For the particular error you mention then if you look for all places
where you assign something to someVariable.l you will likely find
there are only a few places where someVariable could be nul.

Colin

Dave C-J

unread,
Apr 12, 2018, 4:04:27 AM4/12/18
to node...@googlegroups.com
and using slightly more descriptive variables rather than just  l  could help...

Nithin B

unread,
Apr 12, 2018, 2:00:07 PM4/12/18
to Node-RED
Yes, I am aware that using variable name 'l' in not right. I just wanted to give the example of the error message.

Any way... For may be couple of time, few days back, I saw the line number and column number in the error message.
That is when I got doubt that why it displayed position info only at that time.
Reply all
Reply to author
Forward
0 new messages