Skip to content

Commit

Permalink
Make errors in peakwidths! more friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
KronosTheLate committed Apr 11, 2024
1 parent d168c38 commit 808e242
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/peakwidth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,11 @@ end

function peakwidths!(pks::NamedTuple; strict=true, relheight=0.5, min=nothing, max=nothing)
!hasproperty(pks, :proms) && throw(ArgumentError(
"Argument `pks` is expected to have prominences (`:proms`) already calculated"))
"Argument `pks` is expected to have prominences (`:proms`) already calculated. \nExample fix: `peakwidths!(peakproms!(pks))`"))
if xor(hasproperty(pks, :widths), hasproperty(pks, :edges))
throw(ArgumentError("Argument `pks` is expected have neither or both of the fields `:widths` and `:edges`."))
hasproperty(pks, :widths) ?
throw(ArgumentError("Argument `pks` is has property `:widths`, but not field `:edges`. As functions from Peaks.jl only ever add both, this implies unexpected tampering with the peaks provided. To avoid unexpected behaviour, this is an error." )) :
throw(ArgumentError("Argument `pks` is has property `:edges`, but not field `:widths`. As functions from Peaks.jl only ever add both, this implies unexpected tampering with the peaks provided. To avoid unexpected behaviour, this is an error." ))
end
if !hasproperty(pks, :widths)
# Wait to filter until after merging `pks`
Expand Down

0 comments on commit 808e242

Please sign in to comment.