Skip to content

Commit

Permalink
Improving error message style on invalid class name
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Nov 22, 2017
1 parent 39a5604 commit 2930e3c
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 2930e3c

Please sign in to comment.