lib/error_to_send.rb 🔗
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class ErrorToSend < StandardError
+ attr_reader :stanza
+
+ def initialize(stanza)
+ super(stanza.to_s)
+ @stanza = stanza
+ end
+end
Stephen Paul Weber created
lib/error_to_send.rb | 10 ++++++++++
lib/web_register_manager.rb | 4 +++-
sgx_jmp.rb | 5 +++--
3 files changed, 16 insertions(+), 3 deletions(-)
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class ErrorToSend < StandardError
+ attr_reader :stanza
+
+ def initialize(stanza)
+ super(stanza.to_s)
+ @stanza = stanza
+ end
+end
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require_relative "error_to_send"
+
class WebRegisterManager
def initialize
@tel_map = Hash.new { ChooseTel.new }
@@ -35,7 +37,7 @@ class WebRegisterManager
reply.note_text =
"You have not chosen a phone number yet, please return to " \
"https://jmp.chat and choose one now."
- EMPromise.reject(reply)
+ raise ErrorToSend, reply
end
end
end
@@ -36,6 +36,7 @@ require_relative "lib/buy_account_credit_form"
require_relative "lib/command_list"
require_relative "lib/customer"
require_relative "lib/electrum"
+require_relative "lib/error_to_send"
require_relative "lib/em"
require_relative "lib/payment_methods"
require_relative "lib/registration"
@@ -379,8 +380,8 @@ command :execute?, node: "jabber:iq:register", sessionid: nil do |iq|
customer,
web_register_manager
).then(&:write).then { StatsD.increment("registration.completed") }
- }.catch_only(Blather::Stanza) { |reply|
- self << reply
+ }.catch_only(ErrorToSend) { |e|
+ self << e.stanza
}.catch { |e| panic(e, sentry_hub) }
end