Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1061: add 404 message when loading non existing task #1071

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion digiwf-apps/packages/apps/digiwf-tasklist/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ declare module '@vue/runtime-core' {
VListItemTitle: typeof import('vuetify/lib')['VListItemTitle']
VMain: typeof import('vuetify/lib')['VMain']
VMenu: typeof import('vuetify/lib')['VMenu']
VMessages: typeof import('vuetify/lib')['VMessages']
VMultiUserInput: typeof import('./src/components/schema/VMultiUserInput.vue')['default']
VNavigationDrawer: typeof import('vuetify/lib')['VNavigationDrawer']
VProgressCircular: typeof import('vuetify/lib')['VProgressCircular']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {AxiosError} from "axios";


export interface ApiCallError {
readonly message: string
readonly status?: number
}

export const defaultApiErrorHandler = (err: AxiosError): ApiCallError => {
const error: ApiCallError = {
status: err.response?.status,
message: (err.response?.data as any)?.error || "unknown error"
};
return error;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ApiConfig} from "../ApiConfig";
import {PageOfTasks, TaskApiFactory, TasksApiFactory, TaskWithSchema} from "@muenchen/digiwf-task-api-internal";
import {AxiosError} from "axios";
import {TaskVariables} from "../../middleware/tasks/tasksModels";
import {defaultApiErrorHandler} from "../defaultErrorHandler";

export const callGetTasksFromTaskService = (page: number, size: number, query?: string, tag?: string, followUp?: string, sort?: string): Promise<PageOfTasks> => {
// follow-up: YYYY-MM-dd: e.g. 2023-04-17
Expand Down Expand Up @@ -42,7 +43,7 @@ export const callGetTaskDetailsFromTaskService = (taskId: string): Promise<TaskW
const cfg = ApiConfig.getTasklistAxiosConfig(FetchUtils.getGETConfig());
return TaskApiFactory(cfg).getTaskWithSchemaByTaskId(taskId)
.then((res) => Promise.resolve(res.data))
.catch((err: AxiosError) => Promise.reject(FetchUtils.defaultCatchHandler(err, "Die Aufgabe konnte nicht geladen werden.")));
.catch((err: AxiosError) => Promise.reject(defaultApiErrorHandler(err)));
};

export const callCancelTaskInTaskService = (taskId: string): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import {
import {computed, ref, Ref} from "vue";
import {Page} from "../commonModels";
import {HumanTask, HumanTaskDetails, TaskVariables} from "./tasksModels";
import {
mapTaskDetailsFromTaskService,
mapTaskFromTaskService,
} from "./taskMapper";
import {mapTaskDetailsFromTaskService, mapTaskFromTaskService,} from "./taskMapper";
import {useStore} from "../../hooks/store";
import axios, {AxiosError} from "axios";
import {dateToIsoDateTime, getCurrentDate} from "../../utils/time";
import router from "../../router";
import {queryClient} from "../queryClient";
Expand All @@ -33,6 +29,7 @@ import {
isInFinishedProcesses
} from "./mutatedTaskFilter";
import {nullToUndefined} from "../../utils/dataTransformations";
import {ApiCallError} from "../../api/defaultErrorHandler";

const extractTag = (tag: Ref<string | undefined>): string | undefined => {
const currentValue = tag.value;
Expand Down Expand Up @@ -222,8 +219,8 @@ export const loadTask = (taskId: string): Promise<LoadTaskResult> => {
});
});

}).catch((error: Error | AxiosError) => {
if (axios.isAxiosError(error) && (error as AxiosError).status === 404) {
}).catch((error: ApiCallError) => {
if (error.status === 404) {
return Promise.resolve({
error: "Die Aufgabe oder der zugehörige Vorgang wurden bereits abgeschlossen. Die Aufgabe kann daher nicht mehr angezeigt oder bearbeitet werden."
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package de.muenchen.oss.digiwf.task.service.application.port.out.polyflow;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
* Signals that the task with given id is not available.
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
simonhir marked this conversation as resolved.
Show resolved Hide resolved
public class TaskNotFoundException extends RuntimeException {
/**
* Creates new exception with corresponding error message.
Expand Down
Loading