~singpolyma/sgx-jmp

a58d09c7b6ea4593e710f1674e07834abf852199 — Stephen Paul Weber 1 year, 1 month ago 75362f5
Explicitly wrap errors we want to send
3 files changed, 16 insertions(+), 3 deletions(-)

A lib/error_to_send.rb
M lib/web_register_manager.rb
M sgx_jmp.rb
A lib/error_to_send.rb => lib/error_to_send.rb +10 -0
@@ 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

M lib/web_register_manager.rb => lib/web_register_manager.rb +3 -1
@@ 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

M sgx_jmp.rb => sgx_jmp.rb +3 -2
@@ 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