Skip to content

Commit

Permalink
Merge pull request #771 from jClugstor/solution_strip_error
Browse files Browse the repository at this point in the history
use custom exception for lazy interpolation
  • Loading branch information
ChrisRackauckas authored Aug 27, 2024
2 parents 2c3c46d + f8ee074 commit 7f9dd30
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/solutions/ode_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,15 @@ function sensitivity_solution(sol::ODESolution, u, t)
return @set sol.interp = interp
end

struct LazyInterpolationException <: Exception
var::Symbol
end

Base.showerror(io::IO, e::LazyInterpolationException) = print(io, "The algorithm", e.var, " uses lazy interpolation, which is incompatible with `strip_solution`.")

function strip_solution(sol::ODESolution)
if has_lazy_interpolation(sol.alg)
error("The algorithm $(sol.alg) uses lazy interpolation, which is incompatible with
solution stripping.")
throw(LazyInterpolationException(nameof(typeof(sol.alg))))
end

interp = strip_interpolation(sol.interp)
Expand Down

0 comments on commit 7f9dd30

Please sign in to comment.