Error Handler by Function

3 posts / 0 new
Last post
chdarc
Offline
Joined: 06/13/2016 - 14:53
Error Handler by Function

Hello, 
I've written a set of functions within a single script that completes various tasks. Each function has its own error handler with the intention of logging which function the error occurred so I can quickly isolate a potential problem to one single function. However, during my testing I've noted that when an error occurs in one of the functions it calls the error handler in all of them. Is there a way to fix this or perhaps build a single error handler for the whole script that will log from which function the error originates. 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Chris,

Maybe you can share part of your script.  I am not sure what you mean by "when an error occurs in one of the functions it calls the error handler in all of them"?  

So are you checking if there is an error code for each function?  Once an error code is thrown it does not get reset, you need to reset it, so that could be the problem in that your functions are testing for an error number that wasn't reset.

There are different ways I have seen to do this.  You can do this through creating a text file and adding on each error to the text file or you can create a log IDEA file and add to the IDEA file whenever you find an error.

Let me know if this helps out any.

Brian

chdarc
Offline
Joined: 06/13/2016 - 14:53

Hi Brian, 
Thanks for the quick response. 
I think your right in that I am not resetting the error code so it loops through. I'll try that and see what it does. 
I have my code writing the error code to a text file with the intention of the script identifying which function the error occured along with the error code so I can quickly go back and at least narrow my search to a specific area. This will be especially useful when I have multiple people with no code knowledge using the script and unable to tell me where the error occured in the process since they do not know the code.