refactor(voice): raise typed Voice::CallErrors::CallFailed instead of StandardError

This commit is contained in:
Tanmay Deep Sharma
2026-04-30 14:43:44 +07:00
parent 17e25fa3c4
commit e2b3965a08
2 changed files with 3 additions and 3 deletions
@@ -80,6 +80,6 @@ module Enterprise::Whatsapp::Providers::WhatsappCloudService
raise Voice::CallErrors::NoCallPermission, error_msg if error_code == 138_006
raise StandardError, error_msg
raise Voice::CallErrors::CallFailed, error_msg
end
end
@@ -58,12 +58,12 @@ describe Whatsapp::Providers::WhatsappCloudService do
.to raise_error(Voice::CallErrors::NoCallPermission, 'No call permission')
end
it 'raises StandardError with a fallback message when the error body is non-JSON' do
it 'raises Voice::CallErrors::CallFailed with a fallback message when the error body is non-JSON' do
stub_request(:post, calls_url).to_return(status: 502, body: '<html>502 Bad Gateway</html>',
headers: { 'Content-Type' => 'text/html' })
expect { service.initiate_call('15551234567', 'sdp_offer') }
.to raise_error(StandardError, 'Failed to initiate call')
.to raise_error(Voice::CallErrors::CallFailed, 'Failed to initiate call')
end
end
end