Output Line in Error Log

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
jackdleach
Newbie
Posts: 5
Joined: Mon Jan 26, 2015 5:38 am

Output Line in Error Log

Post by jackdleach » Tue Jan 27, 2015 4:22 pm

Hello,

Is there a way to determine the line that threw an error?

Thanks,
-jack

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

Re: Output Line in Error Log

Post by Marcus Tettmar » Wed Jan 28, 2015 4:38 pm

Yes, use the LAST_ERROR_LINE variable.

When an error occurs you will see these variables in the watch list:

LAST_ERROR=description of error
LAST_ERROR_LINE=line number that caused the error.

These are very useful when combined with a custom error handler which could e.g. write to a log file and/or alert you via email etc.

https://www.mjtnet.com/manual/index.htm ... ndling.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

jackdleach
Newbie
Posts: 5
Joined: Mon Jan 26, 2015 5:38 am

Re: Output Line in Error Log

Post by jackdleach » Sat Jan 31, 2015 12:17 pm

Got it, thanks... must have missed the _LINE in the docs (I had been using LAST_ERROR but wanted to trace where it was throwing from).

As a side note, is there a way to raise an error?

jackdleach
Newbie
Posts: 5
Joined: Mon Jan 26, 2015 5:38 am

Re: Output Line in Error Log

Post by jackdleach » Sat Jan 31, 2015 12:38 pm

>> is there a way to raise an error? <<

For example, I use UIAccessibleList to check the contents of a window before performing an action, and I can't find a substring in that list, I'd like to throw an error.

I can manage it easily enough using a custom SRT but an error would keep things semantic.

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

Re: Output Line in Error Log

Post by Marcus Tettmar » Tue Feb 03, 2015 11:25 am

Well if you already have a custom error routine just call it and set LAST_ERROR to whatever you want first.
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