sancarn / stdVBA

VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.
MIT License
295 stars 60 forks source link

stdFiber - Issue when errors occur #83

Closed sancarn closed 1 year ago

sancarn commented 1 year ago
'Calls current sub-process in the fiber procedure. Advances the queue if the ran sub-process is finished.
'@returns {Boolean} True if this fiber procedure has finished execution (i.e. future stepping not required anymore)
Friend Function protStep(ByVal Agent As Object) As Boolean
  On Error GoTo ErrorHandler
    Set This.Agent = Agent

    Dim oMe As Object: Set oMe = Me
    If This.procs(This.procStep).Run(oMe) Then
      This.procStep = This.procStep + 1
      This.isFinished = This.procStep > This.procsCount
    End If
    protStep = This.isFinished
    Exit Function
  On Error GoTo 0
ErrorHandler:
  protStep = True               '<==== This needs to be true, else process will fail
  This.isFinished = True
  This.Result = Null
  This.ErrorText = Err.Description & "(" & Err.Number & ", " & Err.Source & ")"
End Function
sancarn commented 1 year ago

Should add an OnError callback to RunFibers()