Improve error handling for compiler extensions

This commit is contained in:
netkas 2024-09-18 15:20:04 -04:00
parent 3160ddfa27
commit 3adc1b81fb

View file

@ -103,7 +103,6 @@
*/
public function getExtension(): CompilerExtensions
{
// TODO: Update usages from here
return $this->extension;
}
@ -243,9 +242,12 @@
throw new ConfigurationException('The property \'project.compiler.extension\' must not be null.');
}
return new self(Functions::array_bc($data, 'extension'),
Functions::array_bc($data, 'maximum_version'),
Functions::array_bc($data, 'minimum_version')
);
$extension = CompilerExtensions::tryFrom(Functions::array_bc($data, 'extension'));
if($extension === null)
{
throw new ConfigurationException('The property \'project.compiler.extension\' is not a valid extension');
}
return new self($extension, Functions::array_bc($data, 'maximum_version'), Functions::array_bc($data, 'minimum_version'));
}
}