TSK-1993 InvalidArgumentException extends TaskanaRuntimeException
This commit is contained in:
parent
20d389a7d5
commit
f9e6b26817
|
@ -1,7 +1,7 @@
|
|||
package pro.taskana.common.api.exceptions;
|
||||
|
||||
/** This exception is thrown when a method is called with an invalid argument. */
|
||||
public class InvalidArgumentException extends TaskanaException {
|
||||
public class InvalidArgumentException extends TaskanaRuntimeException {
|
||||
|
||||
public static final String ERROR_KEY = "INVALID_ARGUMENT";
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import static java.util.function.Predicate.not;
|
|||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -1580,8 +1579,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
Iterator<String> taskIdIterator) {
|
||||
String currentTaskId = taskIdIterator.next();
|
||||
if (currentTaskId == null || currentTaskId.equals("")) {
|
||||
bulkLog.addError(
|
||||
"", new InvalidArgumentException("IDs with EMPTY or NULL value are not allowed."));
|
||||
bulkLog.addError("", new TaskNotFoundException(null));
|
||||
taskIdIterator.remove();
|
||||
} else {
|
||||
MinimalTaskSummary foundSummary =
|
||||
|
@ -1620,8 +1618,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
CallbackState desiredCallbackState) {
|
||||
String currentExternalId = externalIdIterator.next();
|
||||
if (currentExternalId == null || currentExternalId.equals("")) {
|
||||
bulkLog.addError(
|
||||
"", new InvalidArgumentException("IDs with EMPTY or NULL value are not allowed."));
|
||||
bulkLog.addError("", new TaskNotFoundException(null));
|
||||
externalIdIterator.remove();
|
||||
} else {
|
||||
Optional<MinimalTaskSummary> foundSummary =
|
||||
|
@ -1681,15 +1678,12 @@ public class TaskServiceImpl implements TaskService {
|
|||
break;
|
||||
default:
|
||||
return Optional.of(
|
||||
new InvalidArgumentException(
|
||||
String.format(
|
||||
"desired callbackState has to be in '%s'",
|
||||
Arrays.toString(
|
||||
new CallbackState[] {
|
||||
CallbackState.CALLBACK_PROCESSING_COMPLETED,
|
||||
CallbackState.CLAIMED,
|
||||
CallbackState.CALLBACK_PROCESSING_REQUIRED
|
||||
}))));
|
||||
new InvalidCallbackStateException(
|
||||
foundSummary.getTaskId(),
|
||||
currentTaskCallbackState,
|
||||
CallbackState.CALLBACK_PROCESSING_COMPLETED,
|
||||
CallbackState.CLAIMED,
|
||||
CallbackState.CALLBACK_PROCESSING_REQUIRED));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ final class TaskTransferrer {
|
|||
Set<String> sourceWorkbasketIds, String taskId, TaskSummary taskSummary) {
|
||||
TaskanaException error = null;
|
||||
if (taskId == null || taskId.isEmpty()) {
|
||||
error = new InvalidArgumentException("TaskId should not be null or empty");
|
||||
error = new TaskNotFoundException(null);
|
||||
} else if (taskSummary == null) {
|
||||
error = new TaskNotFoundException(taskId);
|
||||
} else if (taskSummary.getState().isEndState()) {
|
||||
|
|
|
@ -294,8 +294,8 @@ class TransferTaskAccTest extends AbstractAccTest {
|
|||
.isEqualTo(TaskNotFoundException.class);
|
||||
assertThat(results.getErrorForId("TKI:100000000000000000000000000000000006").getClass())
|
||||
.isEqualTo(InvalidTaskStateException.class);
|
||||
assertThat(results.getErrorForId("").getClass()).isEqualTo(InvalidArgumentException.class);
|
||||
assertThat(results.getErrorForId(null).getClass()).isEqualTo(InvalidArgumentException.class);
|
||||
assertThat(results.getErrorForId("").getClass()).isEqualTo(TaskNotFoundException.class);
|
||||
assertThat(results.getErrorForId(null).getClass()).isEqualTo(TaskNotFoundException.class);
|
||||
|
||||
// verify valid requests
|
||||
Task transferredTask = taskService.getTask("TKI:000000000000000000000000000000000006");
|
||||
|
|
|
@ -137,7 +137,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
|||
BeanInstantiationException ex, WebRequest req) {
|
||||
if (ex.getCause() instanceof InvalidArgumentException) {
|
||||
InvalidArgumentException cause = (InvalidArgumentException) ex.getCause();
|
||||
return handleTaskanaException(cause, req);
|
||||
return handleTaskanaRuntimeException(cause, req);
|
||||
}
|
||||
return buildResponse(null, ex, req, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue