Skip to content

Commit

Permalink
Merge pull request #133 from JuliaGizmos/teh/onerror
Browse files Browse the repository at this point in the history
"Deprecation" for onerror
  • Loading branch information
shashi committed Apr 20, 2017
2 parents a7f4e2a + 7f82d1a commit 45cd552
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,6 @@ os:
- linux
- osx
julia:
- 0.4
- 0.5
- nightly
sudo: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
@@ -1,2 +1,2 @@
julia 0.4
julia 0.5
DataStructures
2 changes: 0 additions & 2 deletions appveyor.yml
@@ -1,7 +1,5 @@
environment:
matrix:
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
Expand Down
27 changes: 19 additions & 8 deletions src/core.jl
Expand Up @@ -28,8 +28,8 @@ else
preservers::Dict
name::String
bt
function Signal(v, parents, actions, alive, pres, name)
n=new(v,parents,actions,alive,pres,name, backtrace())
function (::Type{Signal{T}}){T}(v, parents, actions, alive, pres, name)
n=new{T}(v,parents,actions,alive,pres,name, backtrace())
nodes[n] = nothing
finalizer(n, log_gc)
n
Expand Down Expand Up @@ -187,10 +187,14 @@ const _messages = Channel{Nullable{Message}}(CHANNEL_SIZE)
Queue an update to a signal. The update will be propagated when all currently
queued updates are done processing.
The third optional argument is a callback to be called in case the update
ends in an error. The callback receives 3 arguments: the signal, the value,
and a `CapturedException` with the fields `ex` which is the original exception
object, and `processed_bt` which is the backtrace of the exception.
The third (optional) argument, `onerror`, is a callback triggered when
the update ends in an error. The callback receives 4 arguments,
`onerror(sig, val, node, capex)`, where `sig` and `val` are the Signal
and value that `push!` was called with, respectively, `node` is the
Signal whose action triggered the error, and `capex` is a
`CapturedException` with the fields `ex` which is the original
exception object, and `processed_bt` which is the backtrace of the
exception.
The default error callback will print the error and backtrace to STDERR.
"""
Expand Down Expand Up @@ -241,11 +245,18 @@ function run(n::Int=typemax(Int))
end
catch err
if isa(err, InterruptException)
println("Reactive event loop was inturrupted.")
println("Reactive event loop was interrupted.")
rethrow()
else
bt = catch_backtrace()
msgval.onerror(msgval.node, msgval.value, node, CapturedException(err, bt))
try
msgval.onerror(msgval.node, msgval.value, node, CapturedException(err, bt))
catch err_onerror
if isa(err_onerror, MethodError)
println(STDERR, "The syntax for `onerror` has changed, see ?push!")
end
rethrow()
end
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions src/deprecation.jl
@@ -1,4 +1,4 @@
import Base: consume, foldl, call, @deprecate, @deprecate_binding
import Base: consume, foldl, @deprecate, @deprecate_binding
export lift, consume, foldl, keepwhen, keepif, dropif, dropwhen

@deprecate_binding Input Signal
Expand All @@ -10,6 +10,3 @@ export lift, consume, foldl, keepwhen, keepif, dropif, dropwhen
@deprecate keepif filter
@deprecate dropif(f, default, signal) filter(x -> !f(x), default, signal)
@deprecate dropwhen(predicate, x, signal) filterwhen(map(!, predicate), x, signal)
if VERSION < v"0.5.0-dev"
@deprecate call{T}(::Type{Signal{T}}, x) Signal(T, x)
end
2 changes: 1 addition & 1 deletion test/basics.jl
Expand Up @@ -63,7 +63,7 @@ facts("Basic checks") do
# precedence to b over a -- a is older.
@fact value(e) --> value(b)

c = map(_->_, a) # Make a younger than b
c = map(identity, a) # Make a younger than b
f = merge(d, c, b)
push!(a, number())
step()
Expand Down

0 comments on commit 45cd552

Please sign in to comment.