Revision 51556af0
Added by Marc Dequènes over 13 years ago
- ID 51556af000511e0a488faf03a33e80303ec93a76
lib/cyborghood/cyborg/botnet/dsl.rb | ||
---|---|---|
when :decline
|
||
# TODO: remove this case ???
|
||
when :error
|
||
subtask.errors << reply[:exception]
|
||
subtask.errors += reply[:exceptions]
|
||
end
|
||
|
||
subtask.finish
|
||
... | ... | |
when :decline
|
||
# TODO: remove this case ???
|
||
when :error
|
||
subtask.errors << reply[:exception]
|
||
subtask.errors += reply[:exceptions]
|
||
end
|
||
|
||
subtask.finish
|
lib/cyborghood/cyborg/botnet/protocol.rb | ||
---|---|---|
|
||
def process_request_result(result)
|
||
# TODO: better processing of result (info/warnings/…)
|
||
if result[:errors]
|
||
send_error_action(result[:reply_message], result[:errors])
|
||
else
|
||
if result[:errors].empty?
|
||
send_reply_result(result[:reply_message], result[:results])
|
||
else
|
||
send_error_action(result[:reply_message], result[:errors])
|
||
end
|
||
end
|
||
|
||
... | ... | |
|
||
def receive_request_call(message)
|
||
if message.action_parameters.nil?
|
||
return send_error_action(message, {
|
||
return send_error_action(message, [{
|
||
:category => 'API',
|
||
:severity => :unrecoverable,
|
||
:message => "missing parameters"
|
||
})
|
||
}])
|
||
end
|
||
|
||
send_reply_ack(message)
|
||
... | ... | |
end
|
||
|
||
def receive_error_action(message)
|
||
# TODO: do not trust reeived message.action_parameters format
|
||
message.pop_callback do |cb|
|
||
if cb
|
||
error = message.action_parameters[:error]
|
||
exception = CyberError.new(error[:severity], error[:category], error[:message])
|
||
cb.call({:status => :error, :exception => exception})
|
||
exceptions = message.action_parameters[:errors].collect do |error|
|
||
CyberError.new(error[:severity], error[:category], error[:message])
|
||
end
|
||
cb.call({:status => :error, :exceptions => exceptions})
|
||
else
|
||
send_error_protocol("received reply for unknown action")
|
||
end
|
||
... | ... | |
@conversation.set_error_status(fatal)
|
||
end
|
||
|
||
def send_error_action(recv_message, error)
|
||
recv_message.create_reply("ERROR ACTION", { :error => error }).send
|
||
def send_error_action(recv_message, errors)
|
||
recv_message.create_reply("ERROR ACTION", { :errors => errors }).send
|
||
end
|
||
|
||
def send_notify_thread_closed(conv_thread)
|
Also available in: Unified diff
[evol] Protocol: allow returning multiple errors