Rescue validation errors in Packages::TerraformModule::CreatePackageService
Context
When uploading a Terraform module, we have a couple of validations to run before persisting the record in the database. When one of those validations fails, we should rescue from it and gracefully return it to the user with the error message.
Currently, the validation errors are causing such errors and returned as 500 Internal Server Error
.
Solution
In Packages::TerraformModule::CreatePackageService, we should rescue from any validation errors and return them as a ServiceResponse.error
, similar to what we do in Packages::Maven::CreatePackageService