# Handle exception with the problem interface of DifferentialEquations

**URL:** <https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228>\
**Category:** General Usage\
**Tags:** diffeq\
**Created:** [February 5, 2020, 10:44pm UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228 "2020-02-05T22:44:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [February 5, 2020, 10:44pm UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228/1 "2020-02-05T22:44:02Z")

</div>

Hello,

I have an ODE problem with multiple callbacks (continuous and discrete ones). For some initial conditions, the computation of the right hand side will return an `ArgumentError`, is it possible to use the function `terminate` inside the right hand side to kill the resolution of the ODE problem as soon as the exception `ArgumentError` pops up?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 5, 2020, 11:40pm UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228/2 "2020-02-05T23:40:40Z")

</div>

> [@mleprovost](#):
>
> is it possible to use the function `terminate` inside the right hand side to kill the resolution of the ODE problem as soon as the exception `ArgumentError` pops up?

No you can’t, but the bigger question is, why are you getting an ArgumentError?

---

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [February 6, 2020, 12:19am UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228/3 "2020-02-06T00:19:17Z")

</div>

Are Callback conditions checked once the whole right hand side is constructed?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 6, 2020, 4:26am UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228/4 "2020-02-06T04:26:10Z")

</div>

I don’t understand the question.

---

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [February 6, 2020, 5:43am UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228/5 "2020-02-06T05:43:56Z")

</div>

Let’s imagine that I have a state vector `R` of dimension 2 and a callback with a condition on `R[1]`. Can I construct `dR[1]`, then test the condition associated with the callback before to construct the `dR[2]`. Or do I have to construct `dR[1:2]` before the callback’s condition is tested?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 6, 2020, 2:25pm UTC](https://discourse.julialang.org/t/handle-exception-with-the-problem-interface-of-differentialequations/34228/6 "2020-02-06T14:25:45Z")

</div>

No, temporally it doesn’t work out since the callback is called after multiple `f` calls.
