Skip to content

Commit

Permalink
use Julia Logger for reporting exception traces
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmaykm committed Dec 23, 2019
1 parent 7e5f859 commit 4e20136
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/APIResponder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function call_api(api::APISpec, conn::APIResponder, args, data::Dict{Symbol,Any}
result = dynamic_invoke(conn, api.fn, args...; data...)
respond(conn, api, :success, result)
catch ex
logerr("api_exception: ", ex)
@error("api_exception", exception=(ex, backtrace()))
respond(conn, api, :api_exception, string(ex))
end
end
Expand Down Expand Up @@ -163,7 +163,7 @@ function process(conn::APIResponder; async::Bool=false)
try
call_api(conn.endpoints[command], conn, args(conn.format, msg), data(conn.format, msg))
catch ex
logerr("exception ", ex)
@error("exception in process", exception=(ex, backtrace()))
respond(conn, conn.endpoints[command], :invalid_data)
end
end
Expand All @@ -190,10 +190,3 @@ function create_responder(apispecs::Array, addr, bind, nid, open=false)
end
api
end

function logerr(msg, ex)
iob = IOBuffer()
write(iob, msg)
showerror(iob, ex)
@error(String(take!(iob)))
end
3 changes: 1 addition & 2 deletions src/http_rpc_server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ function http_handler(apis::Channel{APIInvoker{T,F}}, preproc::Function, req::HT
end
catch e
res = HTTP.Response(500)
Base.showerror(stderr, e, catch_backtrace())
@error("Exception in handler: ", e)
@error("Exception in handler: ", exception=(e, backtrace()))
end
@debug("response", res)
return res
Expand Down

0 comments on commit 4e20136

Please sign in to comment.