diff --git a/src/Graviton/GeneratorBundle/Command/GenerateDynamicBundleCommand.php b/src/Graviton/GeneratorBundle/Command/GenerateDynamicBundleCommand.php
index b70e9344b..bc6d4cbdd 100644
--- a/src/Graviton/GeneratorBundle/Command/GenerateDynamicBundleCommand.php
+++ b/src/Graviton/GeneratorBundle/Command/GenerateDynamicBundleCommand.php
@@ -296,48 +296,39 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bundleDir = $input->getOption('srcDir').$namespace;
$bundleNamespace = str_replace('/', '\\', $namespace).'\\';
- try {
- $thisHash = sha1($templateHash.PATH_SEPARATOR.serialize($jsonDef));
-
- $needsGeneration = true;
- if (isset($existingBundles[$bundleDir])) {
- if ($existingBundles[$bundleDir] == $thisHash) {
- $needsGeneration = false;
- }
- unset($existingBundles[$bundleDir]);
- }
+ $thisHash = sha1($templateHash.PATH_SEPARATOR.serialize($jsonDef));
- if ($needsGeneration) {
- $this->generateBundle($bundleNamespace, $bundleName, $input->getOption('srcDir'));
- $this->generateGenerationHashFile($bundleDir, $thisHash);
+ $needsGeneration = true;
+ if (isset($existingBundles[$bundleDir])) {
+ if ($existingBundles[$bundleDir] == $thisHash) {
+ $needsGeneration = false;
}
+ unset($existingBundles[$bundleDir]);
+ }
- $definedBundles[$bundleDir] = $jsonDef;
-
- if ($needsGeneration) {
- $this->generateResources(
- $filesToWorkOn,
- $jsonDef,
- $bundleName,
- $bundleDir,
- $bundleNamespace
- );
-
- $output->writeln(
- sprintf('Generated "%s" from definition %s', $bundleName, $jsonDef->getId())
- );
- } else {
- $output->writeln(
- sprintf('Using pre-existing "%s"', $bundleName)
- );
- }
- } catch (\Exception $e) {
- $output->writeln(
- sprintf('%s', $e->getMessage())
+ if ($needsGeneration) {
+ $this->generateBundle($bundleNamespace, $bundleName, $input->getOption('srcDir'));
+ $this->generateGenerationHashFile($bundleDir, $thisHash);
+ }
+
+ $definedBundles[$bundleDir] = $jsonDef;
+
+ if ($needsGeneration) {
+ $this->generateResources(
+ $filesToWorkOn,
+ $jsonDef,
+ $bundleName,
+ $bundleDir,
+ $bundleNamespace
);
- // remove failed bundle from list
- array_pop($this->bundleBundleList);
+ $output->writeln(
+ sprintf('Generated "%s" from definition %s', $bundleName, $jsonDef->getId())
+ );
+ } else {
+ $output->writeln(
+ sprintf('Using pre-existing "%s"', $bundleName)
+ );
}
}
diff --git a/src/Graviton/GeneratorBundle/Generator/ResourceGenerator.php b/src/Graviton/GeneratorBundle/Generator/ResourceGenerator.php
index 0552a6375..abcc96b61 100644
--- a/src/Graviton/GeneratorBundle/Generator/ResourceGenerator.php
+++ b/src/Graviton/GeneratorBundle/Generator/ResourceGenerator.php
@@ -348,11 +348,19 @@ function ($synthField) {
$this->generateSerializer($parameters, $bundleDir, $document, $isSubResource);
}
- $this->schemaGenerator->generateSchema(
- $parameters,
- $isSubResource,
- $schemaFile
- );
+ try {
+ $this->schemaGenerator->generateSchema(
+ $parameters,
+ $isSubResource,
+ $schemaFile
+ );
+ } catch (\Exception $e) {
+ throw new \Exception(
+ sprintf('Error generating schema for document "%s". Cannot continue.', $document),
+ 0,
+ $e
+ );
+ }
if ($this->generateModel) {
$this->generateModel($parameters, $bundleDir, $document, $isSubResource);