Skip to content

Commit

Permalink
chore: use showerror for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaLGandhi committed Jun 21, 2024
1 parent 07c9ac5 commit b910d2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 16 additions & 9 deletions src/concrete_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ function DiffEqBase._concrete_solve_adjoint(prob::Union{SciMLBase.AbstractODEPro

if !(p === nothing || p isa SciMLBase.NullParameters)
if !isscimlstructure(p)
error("`p` is not a SciMLStructure. This is required for adjoint sensitivity analysis. For more information,
see the documentation on SciMLStructures.jl for the definition of the SciMLStructures interface.
In particular, adjoint sensitivities only applies to `Tunable`.")
throw(SciMLStructuresCompatiblityError())

Check warning on line 247 in src/concrete_solve.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Compatiblity" should be "Compatibility".
end
end

Expand Down Expand Up @@ -275,9 +273,7 @@ function DiffEqBase._concrete_solve_adjoint(prob::Union{

if !(p === nothing || p isa SciMLBase.NullParameters)
if !isscimlstructure(p) && !isfunctor(p)
error("`p` is not a SciMLStructure. This is required for adjoint sensitivity analysis. For more information,
see the documentation on SciMLStructures.jl for the definition of the SciMLStructures interface.
In particular, adjoint sensitivities only applies to `Tunable`.")
throw(SciMLStructuresCompatiblityError())

Check warning on line 276 in src/concrete_solve.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Compatiblity" should be "Compatibility".
end
end

Expand Down Expand Up @@ -1134,9 +1130,7 @@ function DiffEqBase._concrete_solve_adjoint(prob::Union{SciMLBase.AbstractDiscre

if !(p === nothing || p isa SciMLBase.NullParameters)
if !isscimlstructure(p)
error("`p` is not a SciMLStructure. This is required for adjoint sensitivity analysis. For more information,
see the documentation on SciMLStructures.jl for the definition of the SciMLStructures interface.
In particular, adjoint sensitivities only applies to `Tunable`.")
throw(SciMLStructuresCompatiblityError())

Check warning on line 1133 in src/concrete_solve.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Compatiblity" should be "Compatibility".
end
end

Expand Down Expand Up @@ -1317,6 +1311,19 @@ function Base.showerror(io::IO, e::EnzymeTrackedRealError)
println(io, ENZYME_TRACKED_REAL_ERROR_MESSAGE)
end

const SCIMLSTRUCTURES_ERROR_MESSAGE = """
`p` is not a SciMLStructure. This is required for adjoint sensitivity analysis. For more information,
see the documentation on SciMLStructures.jl for the definition of the SciMLStructures interface.
In particular, adjoint sensitivities only applies to `Tunable`.
"""

struct SciMLStructuresCompatiblityError <: Exception

Check warning on line 1320 in src/concrete_solve.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Compatiblity" should be "Compatibility".
end

function Base.showerror(io::IO, e::SciMLStructuresCompatiblityError)

Check warning on line 1323 in src/concrete_solve.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Compatiblity" should be "Compatibility".
println(io, SCIMLSTRUCTURES_ERROR_MESSAGE)
end

function DiffEqBase._concrete_solve_adjoint(prob::Union{SciMLBase.AbstractDiscreteProblem,
SciMLBase.AbstractODEProblem,
SciMLBase.AbstractDAEProblem,
Expand Down
4 changes: 1 addition & 3 deletions src/sensitivity_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,7 @@ function adjoint_sensitivities(sol, args...;
p = SymbolicIndexingInterface.parameter_values(sol)
if !(p === nothing || p isa SciMLBase.NullParameters)
if !isscimlstructure(p) && !isfunctor(p)
error("`p` is not a SciMLStructure. This is required for adjoint sensitivity analysis. For more information,
see the documentation on SciMLStructures.jl for the definition of the SciMLStructures interface.
In particular, adjoint sensitivities only applies to `Tunable`.")
throw(SciMLStructuresCompatiblityError())

Check warning on line 365 in src/sensitivity_interface.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Compatiblity" should be "Compatibility".
end
end

Expand Down

0 comments on commit b910d2c

Please sign in to comment.