Skip to main content

capture error

Greetings.
I am new to ideas, and I have found this forum, which has helped me with some scripts; congratulations to the creator.
 
I have used the routine of executing scripts that were created previously, these are divided into projects and at the same time they are programmed for initial at a certain moment, this comes from versions prior to 11.2 which is the one I currently have, because of this there is a script that does not they execute me.
 
My question is it was possible to create an error catcher, to know where these scripts are failed, since if you manually enter them, they are executed. But since they are automated, it doesn't show me errors, since the program has to be closed.

Brian Element Mon, 05/10/2021 - 09:10

What lines do you want to change?

You can implement an error handler in each function.  Generally I add code to tell me what is processing so if the script stops I know where it stopped.

Sub Main

' Define the error handler.

On Error GoTo ErrorHandler

' Create an error condition.

X = 1 / 0

' Exit the application.

Exit Sub

ErrorHandler:

MsgBox "An error occurred."

End Sub

 

jmax6 Tue, 05/11/2021 - 09:15

Hello, thanks for the help I have worked the two examples here I send a part of the code that I use, as they are automated routines, I would like to take the line where it gives me an error, as the software normally does, for example error in line -156. So have a point where to review the code, in case it has been modified in x time. With the example I can only take the data of the description and the number, try using the content and the option Err.Helpfile, Err.HelpContext, Err.Source. but without results.
 
On Error GoTo error_case
arg1 = true
Call Reporte_PrestamoAccionesLibres_AccionesCedidas()
Exit Sub
error_case:
arg1 = false
arg2 = Err.Source & " - " & Err.description & " - " & err.number
On Error Resume Next
On Error GoTo 0
 
 Here I show the code to call the process.
Client.RunIDEAScriptRV "C:\Users\jestrella\Documents\Mis documentos IDEA\Proyectos IDEA\macros\25_PORCIENTO_ACCIONESCEDIDAS_PRESTAMOS_ACCIONESLIBRES.iss", Arg1, Arg2, Arg3, Arg4
If arg1 = true Then
proceso50 = "25_PORCIENTO_ACCIONESCEDIDAS_PRESTAMOS_ACCIONESLIBRES. - " &Time(fecha)
Else
proceso50 = "Error en proceso 25_PORCIENTO_ACCIONESCEDIDAS_PRESTAMOS_ACCIONESLIBRES. - " &arg2 & " - " &Time(fecha)
End If
 

Brian Element Mon, 05/17/2021 - 13:49

The only real way to do this is in your script place variable like:

line = 105

For the 105 line and when you encounter an error then print it out, but this adds a lot of extra lines to your code but that is about the only way you can get the line number from the script unless you are running it real time and are there to view the error.