RED-5293: 500 for invalid tenant

This commit is contained in:
Ali Oezyetimoglu 2022-11-02 13:29:56 +01:00
parent 0dd7cb049d
commit 92326e82f5
2 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import java.time.OffsetDateTime;
import org.postgresql.util.PSQLException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@ -93,4 +94,13 @@ public class ControllerAdvice {
}
}
@ResponseBody
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public ErrorMessage handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
return new ErrorMessage(OffsetDateTime.now(), e.getMessage());
}
}

View File

@ -63,8 +63,6 @@ public class TenantManagementService {
try (Connection connection = DriverManager.getConnection(tenantRequest.getJdbcUrl(), tenantRequest.getUser(), tenantRequest.getPassword())) {
DataSource tenantDataSource = new SingleConnectionDataSource(connection, false);
runLiquibase(tenantDataSource);
} catch (PSQLException e) {
throw new BadRequestException("Could not connect to database", e);
}
TenantEntity tenantEntity = TenantEntity.builder()