Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e36ea50

Browse files
committed
bug #36517 [Notifier] Fix error handling for Free mobile (fabpot)
This PR was merged into the 5.1-dev branch. Discussion ---------- [Notifier] Fix error handling for Free mobile | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | n/a Looks like the error handling code for Free mobile is a copy/paste from Twilio. /cc @noniagriconomie Commits ------- 6167ce4 [Notifier] Fix error handling for Free mobile
2 parents 2235be0 + 6167ce4 commit e36ea50

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ protected function doSend(MessageInterface $message): void
6666
]);
6767

6868
if (200 !== $response->getStatusCode()) {
69-
$error = $response->toArray(false);
69+
$errors = [
70+
400 => 'Missing required parameter or wrongly formatted message.',
71+
402 => 'Too many messages have been sent too fast.',
72+
403 => 'Service not enabled or wrong credentials.',
73+
500 => 'Server error, please try again later.',
74+
];
7075

71-
throw new TransportException(sprintf('Unable to send the SMS: "%s" (see "%s").', $error['message'], $error['more_info']), $response);
76+
throw new TransportException(sprintf('Unable to send the SMS: error %d: ', $response->getStatusCode()).($errors[$response->getStatusCode()] ?? ''), $response);
7277
}
7378
}
7479
}

0 commit comments

Comments
 (0)