~singpolyma/sgx-jmp

d1a28bd8a2c1f2d064523bcf07407f64e48d443c — Stephen Paul Weber 1 year, 2 days ago 83603be
ErrorToSend => FinalStanza
5 files changed, 16 insertions(+), 18 deletions(-)

M lib/command.rb
D lib/error_to_send.rb
M lib/registration.rb
M lib/web_register_manager.rb
M sgx_jmp.rb
M lib/command.rb => lib/command.rb +15 -3
@@ 27,6 27,14 @@ class Command
	end

	class Execution
		class FinalStanza
			attr_reader :stanza

			def initialize(stanza)
				@stanza = stanza
			end
		end

		attr_reader :customer_repo, :log, :iq

		def initialize(customer_repo, blather, format_error, iq)


@@ 64,7 72,7 @@ class Command
				reply.note_type = type
				reply.note_text = text
			end
			raise ErrorToSend, reply
			EMPromise.reject(FinalStanza.new(reply))
		end

		def sentry_hub


@@ 95,11 103,15 @@ class Command
	protected

		def catch_after(promise)
			promise.catch_only(ErrorToSend) { |e|
			promise.catch_only(FinalStanza) { |e|
				@blather << e.stanza
			}.catch do |e|
				log_error(e)
				finish(@format_error.call(e), type: :error)
				finish(
					@format_error.call(e), type: :error
				).catch_only(FinalStanza) do |to_send|
					@blather << to_send.stanza
				end
			end
		end


D lib/error_to_send.rb => lib/error_to_send.rb +0 -10
@@ 1,10 0,0 @@
# frozen_string_literal: true

class ErrorToSend < StandardError
	attr_reader :stanza

	def initialize(stanza)
		super(stanza.to_s)
		@stanza = stanza
	end
end

M lib/registration.rb => lib/registration.rb +0 -1
@@ 8,7 8,6 @@ require_relative "./alt_top_up_form"
require_relative "./command"
require_relative "./bandwidth_tn_order"
require_relative "./em"
require_relative "./error_to_send"
require_relative "./oob"
require_relative "./web_register_manager"


M lib/web_register_manager.rb => lib/web_register_manager.rb +0 -2
@@ 1,7 1,5 @@
# frozen_string_literal: true

require_relative "error_to_send"

class WebRegisterManager
	def initialize
		@tel_map = Hash.new { ChooseTel.new }

M sgx_jmp.rb => sgx_jmp.rb +1 -2
@@ 48,7 48,6 @@ require_relative "lib/command_list"
require_relative "lib/customer"
require_relative "lib/customer_repo"
require_relative "lib/electrum"
require_relative "lib/error_to_send"
require_relative "lib/em"
require_relative "lib/payment_methods"
require_relative "lib/registration"


@@ 388,7 387,7 @@ Command.new(
		Registration.for(customer, web_register_manager).then(&:write)
	}.then {
		StatsD.increment("registration.completed")
	}.catch_only(ErrorToSend) do |e|
	}.catch_only(Command::Execution::FinalStanza) do |e|
		StatsD.increment("registration.completed")
		EMPromise.reject(e)
	end