diff --git a/web.rb b/web.rb index 1e8a691bde0e592bfaa2ed7a2646a67f5fdffb48..183746b9f4c0017c722d63fdc7dd3a4d629944fc 100644 --- a/web.rb +++ b/web.rb @@ -274,7 +274,7 @@ class Web < Roda customer, params["from"], call_id: params["callId"] ) ]) - }.then do |(customer_id, fwd, ca)| + }.then { |(customer_id, fwd, ca)| call = ca.create_call(fwd, CONFIG[:creds][:account]) { |cc| cc.from = params["from"] cc.application_id = params["applicationId"] @@ -282,13 +282,14 @@ class Web < Roda cc.disconnect_url = url inbound_calls_path(:transfer_complete) } - if call - outbound_transfers[params["callId"]] = call - render :ring, locals: { duration: 300 } - else - render :redirect, locals: { to: inbound_calls_path(:voicemail) } - end - end + next EMPromise.reject(:voicemail) unless call + + outbound_transfers[params["callId"]] = call + render :ring, locals: { duration: 300 } + }.catch { |e| + log_error(e) unless e == :voicemail + render :redirect, locals: { to: inbound_calls_path(:voicemail) } + } end end end