Made exceptions more specific

This commit is contained in:
Dennis Eichhorn 2017-07-25 17:29:51 +02:00
parent 33849c8a1f
commit 7c7977b846

View File

@ -85,14 +85,14 @@ abstract class Enum
*
* @return mixed
*
* @throws \Exception Throws this exception if the constant is not defined in the enum class.
* @throws \UnexpectedValueException Throws this exception if the constant is not defined in the enum class.
*
* @since 1.0.0
*/
public static function getByName(string $name)
{
if (!self::isValidName($name)) {
throw new \Exception('Undefined constant "' . $name . '"');
throw new \UnexpectedValueException($name);
}
return constant('static::' . $name);
@ -105,8 +105,6 @@ abstract class Enum
*
* @return mixed
*
* @throws \Exception Throws this exception if the constant is not defined in the enum class.
*
* @since 1.0.0
*/
public static function getName(string $value)