SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
GetLastError Problem

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
GetLastError Problem
Author Message
Jason Hoskins



Joined: 12 Mar 2004
Posts: 68

Post GetLastError Problem Reply with quote
I am trying to use GetLastError, ideally on the "On Error" section of the job. I cannot get the meesage returned even when using the this method or running the sample code within the help. The message variable is always "". It appears the notification script is run before the error is logged. How do I get around this even if it is within the main script code?
Wed Sep 17, 2008 1:15 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6499

Post Reply with quote
I assume you want to get last error occurred during the job execution. I don't think GetLastError will work in a notification action because the scope of the "last error" is limited to the job and notification action is something that the queue executes in response to job events. When called fro ma notification action it returns last error occurred in that notification action. In other words, this method returns last error occurred in the scope of the "current" script, meaning in that particular script or in user defined functions called from that particular script. Hope this description makes sense.
Wed Sep 17, 2008 2:03 pm View user's profile Send private message
Jason Hoskins



Joined: 12 Mar 2004
Posts: 68

Post Reply with quote
It does make sense but even your example is not returning a message. The file does not exist, it enters the error handling but the GetLastError is empty.

[code]
// setup error handling

OnErrorGoTo NOTIFY_ADMIN

// attempt to delete the file
FileDelete( "c:\\data\\accounts.old" )

NORMAL:
// ... continue normal processing here ...

Exit


NOTIFY_ADMIN:

Dim message, string
// get error message
GetLastError message
Concat "File c:\\data\\accounts.old cannot be deleted. Error: ", message, message
// notify Administrator

messagebox ( message )


// ignore this error and restore default error handling
OnErrorStop
// continue normal processing

GoTo NORMAL
[/code]
Wed Sep 17, 2008 2:41 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6499

Post Reply with quote
You are overwriting the last error by executing a successful operation (Dim is an executable statement)

To see what I mean, move Dim line to the beginning of the script and run your code again. In your case, GetLastError should be the first statement in the error handler.

Alternatively,
Code:
OnErrorContinue
// attempt to delete the file
FileDelete( "c:\\data\\accounts.old" )
GetLastError message
NotEqual message, "", we_got_an_error

Wed Sep 17, 2008 3:10 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.