diff --git a/lib/registration.rb b/lib/registration.rb index e034f17c2336ced86162665d78032986840eadf9..b4f35daecd17fec5de15eecf0621201a87ec4534 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -7,6 +7,7 @@ require "securerandom" require_relative "./alt_top_up_form" require_relative "./bandwidth_tn_order" require_relative "./em" +require_relative "./error_to_send" require_relative "./oob" require_relative "./web_register_manager" @@ -471,8 +472,19 @@ class Registration "sip:#{ERB::Util.url_encode(@reply.to.stripped.to_s)}@sip.cheogram.com" end + def raise_setup_error + @reply.note_type = :error + @reply.note_text = + "There was an error setting up your number, " \ + "please contact JMP support." + raise ErrorToSend, @reply + end + def customer_active_tel_purchased - @customer.register!(@tel).then { + @customer.register!(@tel).catch { |e| + puts e + raise_setup_error + }.then { EMPromise.all([ REDIS.set("catapult_fwd-#{@tel}", cheogram_sip_addr), @customer.fwd_timeout = 25 # ~5 seconds / ring, 5 rings