# An easy way to view system-state when a differential equation solver encounters a warning

**URL:** <https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944>\
**Category:** Modelling & Simulations\
**Tags:** diffeq\
**Created:** [September 2, 2024, 12:48pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944 "2024-09-02T12:48:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VBtheHun](https://avatars.discourse-cdn.com/v4/letter/v/ecccb3/32.png) [@VBtheHun](https://discourse.julialang.org/u/VBtheHun)\
**Post date:** [September 2, 2024, 12:48pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944/1 "2024-09-02T12:48:30Z")

</div>

I am trying to solve a system of differential equations where I run into a `larger Maxiters needed` warning. I suspect that my model has been ill-specified as this appears only for certain parameter values. To figure this out, I would like to log my system state when the solver encounters this error. So far I have tried `try-catch` blocks, but they apparently don’t catch warnings but only errors.

Is there any neat way of implementing this?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 2, 2024, 1:42pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944/2 "2024-09-02T13:42:28Z")

</div>

Hello and welcome to the community 👋

Isn’t the last recorded state in the solution object what you are looking for?

---

<div class="post-metadata">

**Author:** ![VBtheHun](https://avatars.discourse-cdn.com/v4/letter/v/ecccb3/32.png) [@VBtheHun](https://discourse.julialang.org/u/VBtheHun)\
**Post date:** [September 2, 2024, 3:29pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944/3 "2024-09-02T15:29:40Z")

</div>

Hey hey! Thank you!

I am not sure if that is the case. Even though I get this warning, the solver continues to run (sometimes I get the same error multiple times before the solver terminates).

---

<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:** [September 2, 2024, 8:41pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944/4 "2024-09-02T20:41:35Z")

</div>

If it’s a maxiters, then `sol.u[end]` would be that state that it ended on.

---

<div class="post-metadata">

**Author:** ![VBtheHun](https://avatars.discourse-cdn.com/v4/letter/v/ecccb3/32.png) [@VBtheHun](https://discourse.julialang.org/u/VBtheHun)\
**Post date:** [September 19, 2024, 3:47pm UTC](https://discourse.julialang.org/t/an-easy-way-to-view-system-state-when-a-differential-equation-solver-encounters-a-warning/118944/5 "2024-09-19T15:47:16Z")

</div>

False, alarm here. The solver does end after it reaches the `maxiters` error. I had quite simply forgotten about a loop the solver was in!
