ONERROR - What line caused the error?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
djs
Junior Coder
Posts: 47
Joined: Sun Apr 29, 2012 4:21 pm

ONERROR - What line caused the error?

Post by djs » Fri Oct 04, 2013 12:48 pm

I've recently started making use of the ability to create custom onerror messages. This is extremely powerful, but.......

If I write a custom onerror routine, is there a way to know what line caused the error? I can get lost trying to fix a problem when it basically gives me the line number of the onerror routine rather than the line number that sent it to the onerror routine.

Any help with this is appreciated.

Dan

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Oct 04, 2013 2:59 pm

Some error messages include the line number, so for those you can look at LASTERROR and it will tell you. Others don't and there's currently no record of what the line was.

We'll definitely improve that in future.

In the mean time, you could enable logging, have your error handler write to the log file. Later you can then look at the log file, find where your error handler has written to it and just above that will be the offending line that caused the error.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts