Exception: Line Number of Caller

Discuss the future of the AutoHotkey language
egocarib
Posts: 100
Joined: 21 May 2015, 18:21

Exception: Line Number of Caller

02 Feb 2017, 16:56

Although it is still documented in the v2 docs...

http://lexikos.github.io/v2/docs/comman ... #Exception

...this doesn't appear to work in v2:

https://autohotkey.com/board/topic/7148 ... ne-number/

This code shows "3" in the messagebox

Code: Select all

TheCalledFunction()
TheCalledFunction() {
    exception_object := Exception("", -1)
    line_number := exception_object.Line
    MsgBox %line_number%
}
Is that intended?
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Exception: Line Number of Caller

02 Feb 2017, 20:48

i've noticed this too in Yunit. must be something changed about when the exception is triggered, but i dont know. read here:
https://autohotkey.com/v2/v2-changes.htm

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Exception: Line Number of Caller

02 Feb 2017, 20:50

It was an unintended side-effect of built-in functions being included in the call stack in v2. -1 is the Exception function and -2 is its caller.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Exception: Line Number of Caller

02 Feb 2017, 22:58

lexikos wrote:It was an unintended side-effect of built-in functions being included in the call stack in v2. -1 is the Exception function and -2 is its caller.
so will this value stay at -2? and in that case the docs will be updated? or do you plan on changing it to match v1 ?

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Exception: Line Number of Caller

03 Feb 2017, 02:54

Changing it to exclude the Exception function would be the rational choice.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 65 guests