RED-5293: removed IllegalArgumentException in ControllerAdvice and specified it in in TenantsController
This commit is contained in:
parent
e2c4b75ad4
commit
1a1e799d40
@ -1,7 +1,6 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.multitenancy;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
@ -106,12 +106,4 @@ public class ControllerAdvice {
|
||||
return new ErrorMessage(OffsetDateTime.now(), String.format("You have empty/wrong formatted parameters: %s", errorListAsString));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||
@ExceptionHandler(value = IllegalArgumentException.class)
|
||||
public ErrorMessage handleIllegalArgumentException(IllegalArgumentException e) {
|
||||
|
||||
return new ErrorMessage(OffsetDateTime.now(), e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.service.DeploymentKeyService;
|
||||
import com.iqser.red.service.peristence.v1.server.service.TenantManagementService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.multitenancy.TenantRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.multitenancy.TenantResponse;
|
||||
@ -27,7 +28,11 @@ public class TenantsController implements TenantsResource {
|
||||
|
||||
public void createTenant(@Valid @RequestBody TenantRequest tenantRequest) {
|
||||
|
||||
tenantManagementService.createTenant(tenantRequest);
|
||||
try {
|
||||
tenantManagementService.createTenant(tenantRequest);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,7 +36,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@EnableConfigurationProperties(LiquibaseProperties.class)
|
||||
public class TenantManagementService {
|
||||
|
||||
private static final Set<String> SQL_CONNECTION_ERROR_CODES = Set.of("08000", "08003", "08006", "3D000");
|
||||
private static final Set<String> SQL_CONNECTION_ERROR_CODES = Set.of(
|
||||
// connection_exception
|
||||
"08000",
|
||||
// connection_does_not_exist
|
||||
"08003",
|
||||
// connection_failure
|
||||
"08006",
|
||||
// invalid_catalog_name
|
||||
"3D000");
|
||||
|
||||
private final EncryptionDecryptionService encryptionService;
|
||||
|
||||
@ -71,7 +79,6 @@ public class TenantManagementService {
|
||||
DataSource tenantDataSource = new SingleConnectionDataSource(connection, false);
|
||||
runLiquibase(tenantDataSource);
|
||||
} catch (PSQLException e) {
|
||||
log.info("SQL state: {}, msg: {}, localized msg: {}", e.getSQLState(), e.getMessage(), e.getLocalizedMessage());
|
||||
handleClientException(e);
|
||||
handleInternalException(e);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user