# Find where an error occurred in a bunch of command line scripts

I have been using my intuition to solve errors in my Mathematica scripts. But when calculations got more complex and I started getting errors involving code in more participating scripts (a script needs another one which needs another one, etc.), I searched for a way to find a file and line number or something and I found:

How to find line where error occurred in Mathematica notebook?

and

The clearest way to represent Mathematica's evaluation sequence

both of them more appropriate to the notebook (UI) environment. I can probably use a notebook and try to run my script there; but I wonder if there is a better way to work purely command line.

Any ideas?

(I am using Mathematica version 9)

• If you want to work under CLI, one way to debug is to insert Print["your label"] at the place you're interested in. If you want to find a file where the current function is defined in, you may need Trace-family (e.g. TraceScan). Aug 4 '14 at 6:10
• btw. I think it will describe the question better if you state in the title that you are doing the debug under command line. Aug 4 '14 at 6:22
• That's what I've been doing. But when you start having more participating scripts and/or logic gets more elaborated, it becomes harder... Sad that Mathematica does not have "exceptions" but the messaging approach. Aug 4 '14 at 6:23
• There are functions like Assert, Check, etc. might help you beyond the Print approach. Aug 4 '14 at 6:25
• Possibly related: (3837) Aug 4 '14 at 6:26