Skip to content

Commit

Permalink
minor #37 Improving error message style on invalid class name (yceruto)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------

Improving error message style on invalid class name

**before**
![invalid-class-name-bad](https://user-images.githubusercontent.com/2028198/33103664-a044d53c-cef1-11e7-985c-33e36e0d28a7.png)

**after**
![valid-class-name-good](https://user-images.githubusercontent.com/2028198/33103682-b87b10ee-cef1-11e7-9bfc-4c0b51889f1c.png)

Commits
-------

2930e3c Improving error message style on invalid class name
  • Loading branch information
javiereguiluz committed Nov 22, 2017
2 parents 39a5604 + 2930e3c commit 8e7db5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\MakerBundle;

use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;

/**
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
* @author Ryan Weaver <weaverryan@gmail.com>
Expand All @@ -22,7 +24,7 @@ public static function validateClassName(string $className, string $errorMessage
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $className)) {
$errorMessage = $errorMessage ?: sprintf('"%s" is not valid as a PHP class name (it must start with a letter or underscore, followed by any number of letters, numbers, or underscores)', $className);

throw new \RuntimeException($errorMessage);
throw new RuntimeCommandException($errorMessage);
}
}
}

0 comments on commit 8e7db5a

Please sign in to comment.