Skip to content

Commit

Permalink
Use @repl block instead of @example to show errors in documentation w…
Browse files Browse the repository at this point in the history
…ithout workarounds
  • Loading branch information
hersle committed Jan 10, 2025
1 parent 755b3b6 commit 3bc5e15
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions docs/src/basics/Debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@ sys = structural_simplify(sys)

This problem causes the ODE solver to crash:

```@example debug
prob = ODEProblem(sys, [], (0.0, 10.0), [])
sol = solve(prob, Tsit5())
```@repl debug
prob = ODEProblem(sys, [], (0.0, 10.0), []);
sol = solve(prob, Tsit5());
```

This suggests *that* something went wrong, but not exactly *what* went wrong and *where* it did.
In such situations, the `debug_system` function is helpful:

```@example debug
try # workaround to show Documenter.jl error (https://github.com/JuliaDocs/Documenter.jl/issues/1420#issuecomment-770539595) # hide
dsys = debug_system(sys; functions = [sqrt])
dprob = ODEProblem(dsys, [], (0.0, 10.0), [])
dsol = solve(dprob, Tsit5())
catch err # hide
showerror(stderr, err) # hide
end # hide
```@repl debug
dsys = debug_system(sys; functions = [sqrt]);
dprob = ODEProblem(dsys, [], (0.0, 10.0), []);
dsol = solve(dprob, Tsit5());
```

Now we see that it crashed because `u1` decreased so much that it became negative and outside the domain of the `` function.
Expand Down

0 comments on commit 3bc5e15

Please sign in to comment.