Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit c8dab00

Browse files
committed
closes #18
1 parent c7e648c commit c8dab00

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/hyper-operation/server_op.rb

+11-5
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,22 @@ def run_from_client(security_param, controller, operation, params)
7272
end
7373
run(deserialize_params(params))
7474
.then { |r| return { json: { response: serialize_response(r) } } }
75-
.fail do |e|
76-
::Rails.logger.debug "\033[0;31;1mERROR: Hyperloop::ServerOp failed when running #{operation} with params \"#{params}\": #{e}\033[0;30;21m"
77-
return { json: { error: e }, status: 500 }
78-
end
75+
.fail { |e| return handle_exception(e, operation, params) }
7976
end
8077
rescue Exception => e
81-
::Rails.logger.debug "\033[0;31;1mERROR: Hyperloop::ServerOp exception caught when running #{operation} with params \"#{params}\": #{e}\033[0;30;21m"
78+
handle_exception(e, operation, params)
79+
end
80+
81+
def handle_exception(e, operation, params)
82+
if defined? ::Rails
83+
params.delete(:controller)
84+
::Rails.logger.debug "\033[0;31;1mERROR: Hyperloop::ServerOp exception caught when running "\
85+
"#{operation} with params \"#{params}\": #{e}\033[0;30;21m"
86+
end
8287
{ json: { error: e }, status: 500 }
8388
end
8489

90+
8591
def remote(path, *args)
8692
promise = Promise.new
8793
uri = URI("#{path}execute_remote_api")

0 commit comments

Comments
 (0)