Skip to content

Commit 2930e3c

Browse files
committed
Improving error message style on invalid class name
1 parent 39a5604 commit 2930e3c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Validator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Bundle\MakerBundle;
1313

14+
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
15+
1416
/**
1517
* @author Javier Eguiluz <[email protected]>
1618
* @author Ryan Weaver <[email protected]>
@@ -22,7 +24,7 @@ public static function validateClassName(string $className, string $errorMessage
2224
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $className)) {
2325
$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);
2426

25-
throw new \RuntimeException($errorMessage);
27+
throw new RuntimeCommandException($errorMessage);
2628
}
2729
}
2830
}

0 commit comments

Comments
 (0)