JuliaDynamics / DiscreteEvents.jl

Discrete event generation and simulation in Julia
MIT License
56 stars 10 forks source link

No Error Being Caught if Process has one #60

Closed jjd35 closed 9 months ago

jjd35 commented 9 months ago

I noticed that if there is an error in a Prc() Function, that Discrete Events just continues through the simulation without any indication there was a problem.

Here is an example:

#start of test.jl
using DiscreteEvents, Printf

function errorProcess(c::Clock)
    @printf("I'm going to have an error\n")
    error("Found Error")
end

function noErrorProcess(c::Clock)
    @printf("I'm running fine\n")
    delay!(c,0.001)
end
errorPrc = Prc(1,errorProcess)
goodPRc = Prc(2,noErrorProcess)
c = Clock()

process!(c, errorPrc,10)
process!(c,goodPRc,10)
@run! c 0.1

And here is the console output:

julia> include("test.jl")
I'm going to have an error
I'm running fine
I'm running fine
I'm running fine
I'm running fine
I'm running fine
I'm running fine
I'm running fine
I'm running fine
I'm running fine
I'm running fine
"run! finished with 10 clock events, 0 sample steps, simulation time: 0.1"

Is there an easy fix here so that it will actually show the error? Also I haven't found a way to get the debugger to actually break in process! functions.

hdavid16 commented 9 months ago

Yes. This is a known issue: https://github.com/JuliaDynamics/DiscreteEvents.jl/issues/50