Skip to content

Commit 8e7db5a

Browse files
committed
minor #37 Improving error message style on invalid class name (yceruto)
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
2 parents 39a5604 + 2930e3c commit 8e7db5a

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)