Skip to content

Commit 3ead617

Browse files
Stephan SahmStephan Sahm
authored andcommitted
renaming isexception to isfailure in analogy to the Scala datatype and to remove confusion between Const{Exception} and plain Exception
:100644 100644 bcff955 70ef31c M src/Try.jl :100644 100644 07ed659 46eef62 M src/promote_type.jl
1 parent 12b36c2 commit 3ead617

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/DataTypesBasic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module DataTypesBasic
3636
export Identity, isidentity, Const,
3737
Option, isoption, issome, isnone, iftrue, iffalse, getOption,
3838
Either, either, @either, iseither, isleft, isright, getleft, getright, getOption, getleftOption, getrightOption, flip_left_right,
39-
Try, @Try, @TryCatch, istry, issuccess, isexception, Thrown, MultipleExceptions,
39+
Try, @Try, @TryCatch, istry, issuccess, isfailure, Thrown, MultipleExceptions,
4040
ContextManager, @ContextManager
4141

4242
using Compat

src/Try.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ issuccess(::Identity) = true
184184
issuccess(::Const{<:Exception}) = false
185185

186186
"""
187-
isexception(::Identity) = false
188-
isexception(::Const{<:Exception}) = true
187+
isfailure(::Identity) = false
188+
isfailure(::Const{<:Exception}) = true
189189
190190
Similar to [`isleft`](@ref), but only defined for `Const{<:Exception}`. Will
191191
throw MethodError when applied on other `Const`.
192192
"""
193-
isexception(::Identity) = false
194-
isexception(::Const{<:Exception}) = true
193+
isfailure(::Identity) = false
194+
isfailure(::Const{<:Exception}) = true
195195

196196
Base.eltype(::Type{Try{T}}) where T = T
197197
Base.eltype(::Type{Try}) = Any

src/promote_type.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function either_promote_type_fix(T, S)
8181
a = @TryCatch MethodError promote_rule(T, S)
8282
b = @TryCatch MethodError promote_rule(S, T)
8383

84-
if isexception(a) && isexception(b)
84+
if isfailure(a) && isfailure(b)
8585
error("Could not `promote_type{T=$T, S=$S}`, as both `promote_rule(T, S)` and `promote_rule(S, T)` result in
8686
MethodErrors: $a, $b.")
8787
elseif issuccess(a) && issuccess(b)

test/Try.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ using Test
1616
@test !issuccess(@Try error("hi"))
1717
@test_throws MethodError issuccess(Const("other"))
1818

19-
@test isexception(@Try error("hi"))
20-
@test !isexception(@Try 5)
21-
@test_throws MethodError isexception(Const("other"))
19+
@test isfailure(@Try error("hi"))
20+
@test !isfailure(@Try 5)
21+
@test_throws MethodError isfailure(Const("other"))
2222

2323
@test Thrown(ErrorException("one"), []) == Thrown(ErrorException("one"), [])
2424
@test repr(Thrown(ErrorException("some"), [])) == """Thrown(ErrorException("some"))"""

0 commit comments

Comments
 (0)