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