Skip to content

Commit

Permalink
allow argcheck(condition, string) again
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3126 committed Dec 6, 2017
1 parent 47b5008 commit 08ec44e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/ArgCheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ function build_error(code, T::Type{<:Exception}, args...)
ret
end
function build_error(code, msg::AbstractString)
ret = ArgumentError(msg)
warn("`@argcheck condition \"$msg\"` is deprecated. Use `@argcheck condition $ret` instead")
ret
ArgumentError(msg)
end
build_error(code, T::Type{<:Exception}=ArgumentError) = T("$code must hold.")
build_error(code, err::Exception) = err
Expand Down
8 changes: 6 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ end
@argcheck issorted(xs...)
end

@testset "custom message" begin
x = 0
@test_throws ArgumentError @argcheck x > 1 "this should not happen"
@argcheck true "this should not happen"
end

@testset "deprecate" begin

# deprecate
err = @catch_exception_object @argcheck false MyExoticError 1 2
@test err === MyExoticError(1,2)
x = 0
@test_throws ArgumentError @argcheck x > 1 "this should not happen"
end

0 comments on commit 08ec44e

Please sign in to comment.