RED-5293: 500 for invalid tenant
This commit is contained in:
parent
0dd7cb049d
commit
92326e82f5
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user