@@ 103,23 103,26 @@ class Command
protected
def catch_after(promise)
- promise.catch_only(FinalStanza) { |e|
+ promise.catch_only(Blather::Stanza::Iq::Command) { |iq|
+ next EMPromise.reject(iq) unless iq.cancel?
+
+ finish(status: :canceled)
+ }.catch_only(FinalStanza) { |e|
@blather << e.stanza
}.catch do |e|
log_error(e)
- finish(
- @format_error.call(e), type: :error
- ).catch_only(FinalStanza) do |to_send|
- @blather << to_send.stanza
- end
+ send_final_error(e)
+ end
+ end
+
+ def send_final_error(e)
+ finish(@format_error.call(e), type: :error).catch_only(FinalStanza) do |s|
+ @blather << s.stanza
end
end
def log_error(e)
- @log.error(
- "Error raised during #{iq.node}: #{e.class}",
- e
- )
+ @log.error("Error raised during #{iq.node}: #{e.class}", e)
if e.is_a?(::Exception)
sentry_hub.capture_exception(e)
else