@@ 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