AutoHotkey Community

It is currently May 27th, 2012, 6:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: September 28th, 2011, 9:43 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
Is it possible to integrate Exception handling (specifically Throws) inside a RegEx Callout function? I just tried it and it did not work. Then I looked in the documentation, but did not find anything about.

I wanted have a functionality to throw for each line an error, if line is not matching the regex part. It is not really needed, was just debugging my regex. Could help a lot sometimes.

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2011, 1:49 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Code:
try
    RegExMatch("", "(?C1:F)(?C2:F)")
catch e
    MsgBox %e%

F(m, n) {
    MsgBox Callout %n%
    throw "Exception at callout " n
}

It works, but ...
Quote:
If the function returns 0 or does not return a numeric value, matching proceeds as normal.
...
If the function returns -1, matching is abandoned.

I will add some extra handling so that a "FAIL" result (an exception or runtime error which would exit the thread) causes the callout to return a negative value. This has to be done internally, since you can't both return a value and throw an exception.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group