[Intl] Improve the error message when country code is wrong
This commit is contained in:
parent
dd3dc1a684
commit
f4ff47e47e
@ -603,6 +603,15 @@ class TimezonesTest extends ResourceBundleTestCase
|
||||
Timezones::forCountryCode('foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
|
||||
* @expectedExceptionMessage Country codes must be in uppercase, but "nl" was passed. Try with "NL" country code instead.
|
||||
*/
|
||||
public function testForCountryCodeWithWrongCountryCode()
|
||||
{
|
||||
Timezones::forCountryCode('nl');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
|
||||
*/
|
||||
|
@ -109,6 +109,10 @@ final class Timezones extends ResourceBundle
|
||||
return [];
|
||||
}
|
||||
|
||||
if (Countries::exists(strtoupper($country))) {
|
||||
throw new MissingResourceException(sprintf('Country codes must be in uppercase, but "%s" was passed. Try with "%s" country code instead.', $country, strtoupper($country)));
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user