mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-19 03:05:53 +08:00
Improve network error handling
This commit is contained in:
parent
1bee405599
commit
a6498ca729
@ -1,5 +1,6 @@
|
||||
import { Dispatch } from "redux";
|
||||
import { listQueueStats, ListQueueStatsResponse } from "../api";
|
||||
import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
||||
|
||||
export const LIST_QUEUE_STATS_BEGIN = "LIST_QUEUE_STATS_BEGIN";
|
||||
export const LIST_QUEUE_STATS_SUCCESS = "LIST_QUEUE_STATS_SUCCESS";
|
||||
@ -35,10 +36,13 @@ export function listQueueStatsAsync() {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("listQueueStatsAsync: ", error);
|
||||
console.error(
|
||||
"listQueueStatsAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_QUEUE_STATS_ERROR,
|
||||
error: "Could not fetch queue stats",
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
pauseQueue,
|
||||
resumeQueue,
|
||||
} from "../api";
|
||||
import { toErrorString } from "../utils";
|
||||
import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
||||
|
||||
// List of queue related action types.
|
||||
export const LIST_QUEUES_BEGIN = "LIST_QUEUES_BEGIN";
|
||||
@ -109,10 +109,10 @@ export function listQueuesAsync() {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`listQueuesAsync: ${toErrorString(error)}`);
|
||||
console.error(`listQueuesAsync: ${toErrorStringWithHttpStatus(error)}`);
|
||||
dispatch({
|
||||
type: LIST_QUEUES_ERROR,
|
||||
error: error.response.data,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -136,7 +136,7 @@ export function deleteQueueAsync(qname: string) {
|
||||
dispatch({
|
||||
type: DELETE_QUEUE_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not delete queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -148,11 +148,12 @@ export function pauseQueueAsync(qname: string) {
|
||||
try {
|
||||
await pauseQueue(qname);
|
||||
dispatch({ type: PAUSE_QUEUE_SUCCESS, queue: qname });
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error("pauseQueueAsynq: ", toErrorStringWithHttpStatus(error));
|
||||
dispatch({
|
||||
type: PAUSE_QUEUE_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not pause queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -164,11 +165,12 @@ export function resumeQueueAsync(qname: string) {
|
||||
try {
|
||||
await resumeQueue(qname);
|
||||
dispatch({ type: RESUME_QUEUE_SUCCESS, queue: qname });
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error("resumeQueueAsync: ", toErrorStringWithHttpStatus(error));
|
||||
dispatch({
|
||||
type: RESUME_QUEUE_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not resume queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Dispatch } from "redux";
|
||||
import { getRedisInfo, RedisInfoResponse } from "../api";
|
||||
import { toErrorString } from "../utils";
|
||||
import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
||||
|
||||
// List of redis-info related action types.
|
||||
export const GET_REDIS_INFO_BEGIN = "GET_REDIS_INFO_BEGIN";
|
||||
@ -34,10 +34,10 @@ export function getRedisInfoAsync() {
|
||||
const response = await getRedisInfo();
|
||||
dispatch({ type: GET_REDIS_INFO_SUCCESS, payload: response });
|
||||
} catch (error) {
|
||||
console.error(`getRedisInfoAsync: ${toErrorString(error)}`);
|
||||
console.error(`getRedisInfoAsync: ${toErrorStringWithHttpStatus(error)}`);
|
||||
dispatch({
|
||||
type: GET_REDIS_INFO_ERROR,
|
||||
error: error.response.data,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
listSchedulerEntries,
|
||||
ListSchedulerEntriesResponse,
|
||||
} from "../api";
|
||||
import { toErrorString } from "../utils";
|
||||
import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
||||
|
||||
// List of scheduler-entry related action types.
|
||||
export const LIST_SCHEDULER_ENTRIES_BEGIN = "LIST_SCHEDULER_ENTRIES_BEGIN";
|
||||
@ -68,10 +68,12 @@ export function listSchedulerEntriesAsync() {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`listSchedulerEnqueueEventsAsync: ${toErrorString(error)}`);
|
||||
console.error(
|
||||
`listSchedulerEnqueueEventsAsync: ${toErrorStringWithHttpStatus(error)}`
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_SCHEDULER_ENTRIES_ERROR,
|
||||
error: error.response.data,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -88,10 +90,13 @@ export function listSchedulerEnqueueEventsAsync(entryId: string) {
|
||||
entryId,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("listSchedulerEnqueueEventsAsync: ", error);
|
||||
console.error(
|
||||
"listSchedulerEnqueueEventsAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_SCHEDULER_ENQUEUE_EVENTS_ERROR,
|
||||
error: `Could not get enqueue events for entry: ${entryId}`,
|
||||
error: toErrorString(error),
|
||||
entryId,
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Dispatch } from "redux";
|
||||
import { listServers, ListServersResponse } from "../api";
|
||||
import { toErrorString } from "../utils";
|
||||
import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
||||
|
||||
// List of server related action types.
|
||||
export const LIST_SERVERS_BEGIN = "LIST_SERVERS_BEGIN";
|
||||
@ -35,10 +35,10 @@ export function listServersAsync() {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`listServersAsync: ${toErrorString(error)}`);
|
||||
console.error(`listServersAsync: ${toErrorStringWithHttpStatus(error)}`);
|
||||
dispatch({
|
||||
type: LIST_SERVERS_ERROR,
|
||||
error: error.response.data,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -49,6 +49,7 @@ import {
|
||||
archiveAllPendingTasks,
|
||||
} from "../api";
|
||||
import { Dispatch } from "redux";
|
||||
import { toErrorString, toErrorStringWithHttpStatus } from "../utils";
|
||||
|
||||
// List of tasks related action types.
|
||||
export const LIST_ACTIVE_TASKS_BEGIN = "LIST_ACTIVE_TASKS_BEGIN";
|
||||
@ -1017,11 +1018,15 @@ export function listActiveTasksAsync(
|
||||
queue: qname,
|
||||
payload: response,
|
||||
});
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"listActiveTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_ACTIVE_TASKS_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not retreive active tasks data for queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1040,11 +1045,15 @@ export function listPendingTasksAsync(
|
||||
queue: qname,
|
||||
payload: response,
|
||||
});
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"listPendingTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_PENDING_TASKS_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not retreive pending tasks data for queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1063,11 +1072,15 @@ export function listScheduledTasksAsync(
|
||||
queue: qname,
|
||||
payload: response,
|
||||
});
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"listScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_SCHEDULED_TASKS_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not retreive scheduled tasks data for queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1086,11 +1099,15 @@ export function listRetryTasksAsync(
|
||||
queue: qname,
|
||||
payload: response,
|
||||
});
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"listRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_RETRY_TASKS_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not retreive retry tasks data for queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1109,11 +1126,15 @@ export function listArchivedTasksAsync(
|
||||
queue: qname,
|
||||
payload: response,
|
||||
});
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"listArchivedTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: LIST_ARCHIVED_TASKS_ERROR,
|
||||
queue: qname,
|
||||
error: `Could not retreive archived tasks data for queue: ${qname}`,
|
||||
error: toErrorString(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1125,10 +1146,14 @@ export function cancelActiveTaskAsync(queue: string, taskId: string) {
|
||||
try {
|
||||
await cancelActiveTask(queue, taskId);
|
||||
dispatch({ type: CANCEL_ACTIVE_TASK_SUCCESS, queue, taskId });
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"cancelActiveTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: CANCEL_ACTIVE_TASK_ERROR,
|
||||
error: `Could not cancel task: ${taskId}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskId,
|
||||
});
|
||||
@ -1143,10 +1168,13 @@ export function cancelAllActiveTasksAsync(queue: string) {
|
||||
await cancelAllActiveTasks(queue);
|
||||
dispatch({ type: CANCEL_ALL_ACTIVE_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("cancelAllActiveTasksAsync: ", error);
|
||||
console.error(
|
||||
"cancelAllActiveTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: CANCEL_ALL_ACTIVE_TASKS_ERROR,
|
||||
error: "Could not cancel all tasks",
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1164,10 +1192,13 @@ export function batchCancelActiveTasksAsync(queue: string, taskIds: string[]) {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchCancelActiveTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchCancelActiveTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_CANCEL_ACTIVE_TASKS_ERROR,
|
||||
error: `Could not batch cancel tasks: ${taskIds}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskIds,
|
||||
});
|
||||
@ -1182,10 +1213,13 @@ export function runScheduledTaskAsync(queue: string, taskKey: string) {
|
||||
await runScheduledTask(queue, taskKey);
|
||||
dispatch({ type: RUN_SCHEDULED_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("runScheduledTaskAsync: ", error);
|
||||
console.error(
|
||||
"runScheduledTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: RUN_SCHEDULED_TASK_ERROR,
|
||||
error: `Could not run task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1200,10 +1234,10 @@ export function runRetryTaskAsync(queue: string, taskKey: string) {
|
||||
await runRetryTask(queue, taskKey);
|
||||
dispatch({ type: RUN_RETRY_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("runRetryTaskAsync: ", error);
|
||||
console.error("runRetryTaskAsync: ", toErrorStringWithHttpStatus(error));
|
||||
dispatch({
|
||||
type: RUN_RETRY_TASK_ERROR,
|
||||
error: `Could not run task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1218,10 +1252,13 @@ export function archivePendingTaskAsync(queue: string, taskKey: string) {
|
||||
await archivePendingTask(queue, taskKey);
|
||||
dispatch({ type: ARCHIVE_PENDING_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("archivePendingTaskAsync: ", error);
|
||||
console.error(
|
||||
"archivePendingTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: ARCHIVE_PENDING_TASK_ERROR,
|
||||
error: `Could not archive task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1236,10 +1273,13 @@ export function archiveScheduledTaskAsync(queue: string, taskKey: string) {
|
||||
await archiveScheduledTask(queue, taskKey);
|
||||
dispatch({ type: ARCHIVE_SCHEDULED_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("archiveScheduledTaskAsync: ", error);
|
||||
console.error(
|
||||
"archiveScheduledTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: ARCHIVE_SCHEDULED_TASK_ERROR,
|
||||
error: `Could not archive task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1254,10 +1294,13 @@ export function archiveRetryTaskAsync(queue: string, taskKey: string) {
|
||||
await archiveRetryTask(queue, taskKey);
|
||||
dispatch({ type: ARCHIVE_RETRY_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("archiveRetryTaskAsync: ", error);
|
||||
console.error(
|
||||
"archiveRetryTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: ARCHIVE_RETRY_TASK_ERROR,
|
||||
error: `Could not archive task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1272,10 +1315,13 @@ export function runArchivedTaskAsync(queue: string, taskKey: string) {
|
||||
await runArchivedTask(queue, taskKey);
|
||||
dispatch({ type: RUN_ARCHIVED_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("runArchivedTaskAsync: ", error);
|
||||
console.error(
|
||||
"runArchivedTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: RUN_ARCHIVED_TASK_ERROR,
|
||||
error: `Could not run task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1290,10 +1336,13 @@ export function deletePendingTaskAsync(queue: string, taskKey: string) {
|
||||
await deletePendingTask(queue, taskKey);
|
||||
dispatch({ type: DELETE_PENDING_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("deletePendingTaskAsync: ", error);
|
||||
console.error(
|
||||
"deletePendingTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_PENDING_TASK_ERROR,
|
||||
error: `Could not delete task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1315,10 +1364,13 @@ export function batchDeletePendingTasksAsync(
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchDeletePendingTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchDeletePendingTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_DELETE_PENDING_TASKS_ERROR,
|
||||
error: `Could not batch delete tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1333,10 +1385,13 @@ export function deleteScheduledTaskAsync(queue: string, taskKey: string) {
|
||||
await deleteScheduledTask(queue, taskKey);
|
||||
dispatch({ type: DELETE_SCHEDULED_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("deleteScheduledTaskAsync: ", error);
|
||||
console.error(
|
||||
"deleteScheduledTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_SCHEDULED_TASK_ERROR,
|
||||
error: `Could not delete task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1358,10 +1413,13 @@ export function batchDeleteScheduledTasksAsync(
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchDeleteScheduledTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchDeleteScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_DELETE_SCHEDULED_TASKS_ERROR,
|
||||
error: `Could not batch delete tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1380,10 +1438,13 @@ export function batchRunScheduledTasksAsync(queue: string, taskKeys: string[]) {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchRunScheduledTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchRunScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_RUN_SCHEDULED_TASKS_ERROR,
|
||||
error: `Could not batch run tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1405,10 +1466,13 @@ export function batchArchiveScheduledTasksAsync(
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchArchiveScheduledTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchArchiveScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_ARCHIVE_SCHEDULED_TASKS_ERROR,
|
||||
error: `Could not batch archive tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1430,10 +1494,13 @@ export function batchArchivePendingTasksAsync(
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchArchivePendingTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchArchivePendingTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_ARCHIVE_PENDING_TASKS_ERROR,
|
||||
error: `Could not batch archive tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1448,10 +1515,13 @@ export function archiveAllPendingTasksAsync(queue: string) {
|
||||
await archiveAllPendingTasks(queue);
|
||||
dispatch({ type: ARCHIVE_ALL_PENDING_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("archiveAllPendingTasksAsync: ", error);
|
||||
console.error(
|
||||
"archiveAllPendingTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: ARCHIVE_ALL_PENDING_TASKS_ERROR,
|
||||
error: `Could not archive all pending tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1465,10 +1535,13 @@ export function deleteAllPendingTasksAsync(queue: string) {
|
||||
await deleteAllPendingTasks(queue);
|
||||
dispatch({ type: DELETE_ALL_PENDING_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("deleteAllPendingTasksAsync: ", error);
|
||||
console.error(
|
||||
"deleteAllPendingTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_ALL_PENDING_TASKS_ERROR,
|
||||
error: `Could not delete all pending tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1482,10 +1555,13 @@ export function deleteAllScheduledTasksAsync(queue: string) {
|
||||
await deleteAllScheduledTasks(queue);
|
||||
dispatch({ type: DELETE_ALL_SCHEDULED_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("deleteAllScheduledTasksAsync: ", error);
|
||||
console.error(
|
||||
"deleteAllScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_ALL_SCHEDULED_TASKS_ERROR,
|
||||
error: `Could not delete all scheduled tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1499,10 +1575,13 @@ export function runAllScheduledTasksAsync(queue: string) {
|
||||
await runAllScheduledTasks(queue);
|
||||
dispatch({ type: RUN_ALL_SCHEDULED_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("runAllScheduledTasksAsync: ", error);
|
||||
console.error(
|
||||
"runAllScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: RUN_ALL_SCHEDULED_TASKS_ERROR,
|
||||
error: `Could not run all scheduled tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1516,10 +1595,13 @@ export function archiveAllScheduledTasksAsync(queue: string) {
|
||||
await archiveAllScheduledTasks(queue);
|
||||
dispatch({ type: ARCHIVE_ALL_SCHEDULED_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("archiveAllScheduledTasksAsync: ", error);
|
||||
console.error(
|
||||
"archiveAllScheduledTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: ARCHIVE_ALL_SCHEDULED_TASKS_ERROR,
|
||||
error: `Could not archive all scheduled tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1533,10 +1615,13 @@ export function deleteRetryTaskAsync(queue: string, taskKey: string) {
|
||||
await deleteRetryTask(queue, taskKey);
|
||||
dispatch({ type: DELETE_RETRY_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("deleteRetryTaskAsync: ", error);
|
||||
console.error(
|
||||
"deleteRetryTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_RETRY_TASK_ERROR,
|
||||
error: `Could not delete task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1555,10 +1640,13 @@ export function batchDeleteRetryTasksAsync(queue: string, taskKeys: string[]) {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchDeleteRetryTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchDeleteRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_DELETE_RETRY_TASKS_ERROR,
|
||||
error: `Could not batch delete tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1577,10 +1665,13 @@ export function batchRunRetryTasksAsync(queue: string, taskKeys: string[]) {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchRunRetryTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchRunRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_RUN_RETRY_TASKS_ERROR,
|
||||
error: `Could not batch run tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1599,10 +1690,13 @@ export function batchArchiveRetryTasksAsync(queue: string, taskKeys: string[]) {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchArchiveRetryTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchArchiveRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_ARCHIVE_RETRY_TASKS_ERROR,
|
||||
error: `Could not batch archive tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1617,10 +1711,13 @@ export function deleteAllRetryTasksAsync(queue: string) {
|
||||
await deleteAllRetryTasks(queue);
|
||||
dispatch({ type: DELETE_ALL_RETRY_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("deleteAllRetryTasksAsync: ", error);
|
||||
console.error(
|
||||
"deleteAllRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_ALL_RETRY_TASKS_ERROR,
|
||||
error: `Could not delete all retry tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1634,10 +1731,13 @@ export function runAllRetryTasksAsync(queue: string) {
|
||||
await runAllRetryTasks(queue);
|
||||
dispatch({ type: RUN_ALL_RETRY_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("runAllRetryTasksAsync: ", error);
|
||||
console.error(
|
||||
"runAllRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: RUN_ALL_RETRY_TASKS_ERROR,
|
||||
error: `Could not run all retry tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1651,10 +1751,13 @@ export function archiveAllRetryTasksAsync(queue: string) {
|
||||
await archiveAllRetryTasks(queue);
|
||||
dispatch({ type: ARCHIVE_ALL_RETRY_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("archiveAllRetryTasksAsync: ", error);
|
||||
console.error(
|
||||
"archiveAllRetryTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: ARCHIVE_ALL_RETRY_TASKS_ERROR,
|
||||
error: `Could not archive all retry tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1668,10 +1771,13 @@ export function deleteArchivedTaskAsync(queue: string, taskKey: string) {
|
||||
await deleteArchivedTask(queue, taskKey);
|
||||
dispatch({ type: DELETE_ARCHIVED_TASK_SUCCESS, queue, taskKey });
|
||||
} catch (error) {
|
||||
console.error("deleteArchivedTaskAsync: ", error);
|
||||
console.error(
|
||||
"deleteArchivedTaskAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_ARCHIVED_TASK_ERROR,
|
||||
error: `Could not delete task: ${taskKey}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKey,
|
||||
});
|
||||
@ -1693,10 +1799,13 @@ export function batchDeleteArchivedTasksAsync(
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchDeleteArchivedTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchDeleteArchivedTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_DELETE_ARCHIVED_TASKS_ERROR,
|
||||
error: `Could not batch delete tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1715,10 +1824,13 @@ export function batchRunArchivedTasksAsync(queue: string, taskKeys: string[]) {
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("batchRunArchivedTasksAsync: ", error);
|
||||
console.error(
|
||||
"batchRunArchivedTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: BATCH_RUN_ARCHIVED_TASKS_ERROR,
|
||||
error: `Could not batch run tasks: ${taskKeys}`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
taskKeys,
|
||||
});
|
||||
@ -1733,10 +1845,13 @@ export function deleteAllArchivedTasksAsync(queue: string) {
|
||||
await deleteAllArchivedTasks(queue);
|
||||
dispatch({ type: DELETE_ALL_ARCHIVED_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("deleteAllArchivedTasksAsync: ", error);
|
||||
console.error(
|
||||
"deleteAllArchivedTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: DELETE_ALL_ARCHIVED_TASKS_ERROR,
|
||||
error: `Could not delete all archived tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
@ -1750,10 +1865,13 @@ export function runAllArchivedTasksAsync(queue: string) {
|
||||
await runAllArchivedTasks(queue);
|
||||
dispatch({ type: RUN_ALL_ARCHIVED_TASKS_SUCCESS, queue });
|
||||
} catch (error) {
|
||||
console.error("runAllArchivedTasksAsync: ", error);
|
||||
console.error(
|
||||
"runAllArchivedTasksAsync: ",
|
||||
toErrorStringWithHttpStatus(error)
|
||||
);
|
||||
dispatch({
|
||||
type: RUN_ALL_ARCHIVED_TASKS_ERROR,
|
||||
error: `Could not run all archived tasks`,
|
||||
error: toErrorString(error),
|
||||
queue,
|
||||
});
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
function mapStateToProps(state: AppState) {
|
||||
return {
|
||||
loading: state.tasks.activeTasks.loading,
|
||||
error: state.tasks.activeTasks.error,
|
||||
tasks: state.tasks.activeTasks.data,
|
||||
batchActionPending: state.tasks.activeTasks.batchActionPending,
|
||||
allActionPending: state.tasks.activeTasks.allActionPending,
|
||||
@ -133,6 +134,15 @@ function ActiveTasksTable(props: Props & ReduxProps) {
|
||||
|
||||
usePolling(fetchData, pollInterval);
|
||||
|
||||
if (props.error.length > 0) {
|
||||
return (
|
||||
<Alert severity="error">
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
{props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.tasks.length === 0) {
|
||||
return (
|
||||
<Alert severity="info">
|
||||
|
@ -72,6 +72,7 @@ const useRowStyles = makeStyles({
|
||||
function mapStateToProps(state: AppState) {
|
||||
return {
|
||||
loading: state.tasks.archivedTasks.loading,
|
||||
error: state.tasks.archivedTasks.error,
|
||||
tasks: state.tasks.archivedTasks.data,
|
||||
batchActionPending: state.tasks.archivedTasks.batchActionPending,
|
||||
allActionPending: state.tasks.archivedTasks.allActionPending,
|
||||
@ -156,6 +157,14 @@ function ArchivedTasksTable(props: Props & ReduxProps) {
|
||||
|
||||
usePolling(fetchData, pollInterval);
|
||||
|
||||
if (props.error.length > 0) {
|
||||
return (
|
||||
<Alert severity="error">
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
{props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
if (props.tasks.length === 0) {
|
||||
return (
|
||||
<Alert severity="info">
|
||||
|
@ -57,6 +57,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
function mapStateToProps(state: AppState) {
|
||||
return {
|
||||
loading: state.tasks.pendingTasks.loading,
|
||||
error: state.tasks.pendingTasks.error,
|
||||
tasks: state.tasks.pendingTasks.data,
|
||||
batchActionPending: state.tasks.pendingTasks.batchActionPending,
|
||||
allActionPending: state.tasks.pendingTasks.allActionPending,
|
||||
@ -141,6 +142,14 @@ function PendingTasksTable(props: Props & ReduxProps) {
|
||||
|
||||
usePolling(fetchData, pollInterval);
|
||||
|
||||
if (props.error.length > 0) {
|
||||
return (
|
||||
<Alert severity="error">
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
{props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
if (props.tasks.length === 0) {
|
||||
return (
|
||||
<Alert severity="info">
|
||||
|
@ -61,6 +61,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
function mapStateToProps(state: AppState) {
|
||||
return {
|
||||
loading: state.tasks.retryTasks.loading,
|
||||
error: state.tasks.retryTasks.error,
|
||||
tasks: state.tasks.retryTasks.data,
|
||||
batchActionPending: state.tasks.retryTasks.batchActionPending,
|
||||
allActionPending: state.tasks.retryTasks.allActionPending,
|
||||
@ -158,6 +159,14 @@ function RetryTasksTable(props: Props & ReduxProps) {
|
||||
|
||||
usePolling(fetchData, pollInterval);
|
||||
|
||||
if (props.error.length > 0) {
|
||||
return (
|
||||
<Alert severity="error">
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
{props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
if (props.tasks.length === 0) {
|
||||
return (
|
||||
<Alert severity="info">
|
||||
|
@ -61,6 +61,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
function mapStateToProps(state: AppState) {
|
||||
return {
|
||||
loading: state.tasks.scheduledTasks.loading,
|
||||
error: state.tasks.scheduledTasks.error,
|
||||
tasks: state.tasks.scheduledTasks.data,
|
||||
batchActionPending: state.tasks.scheduledTasks.batchActionPending,
|
||||
allActionPending: state.tasks.scheduledTasks.allActionPending,
|
||||
@ -158,6 +159,14 @@ function ScheduledTasksTable(props: Props & ReduxProps) {
|
||||
|
||||
usePolling(fetchData, pollInterval);
|
||||
|
||||
if (props.error.length > 0) {
|
||||
return (
|
||||
<Alert severity="error">
|
||||
<AlertTitle>Error</AlertTitle>
|
||||
{props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
if (props.tasks.length === 0) {
|
||||
return (
|
||||
<Alert severity="info">
|
||||
|
@ -243,7 +243,6 @@ function tasksReducer(
|
||||
...state,
|
||||
activeTasks: {
|
||||
...state.activeTasks,
|
||||
error: "",
|
||||
loading: true,
|
||||
},
|
||||
};
|
||||
@ -270,6 +269,7 @@ function tasksReducer(
|
||||
...state.activeTasks,
|
||||
loading: false,
|
||||
error: action.error,
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
|
||||
@ -278,7 +278,6 @@ function tasksReducer(
|
||||
...state,
|
||||
pendingTasks: {
|
||||
...state.pendingTasks,
|
||||
error: "",
|
||||
loading: true,
|
||||
},
|
||||
};
|
||||
@ -304,6 +303,7 @@ function tasksReducer(
|
||||
...state.pendingTasks,
|
||||
loading: false,
|
||||
error: action.error,
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
|
||||
@ -312,7 +312,6 @@ function tasksReducer(
|
||||
...state,
|
||||
scheduledTasks: {
|
||||
...state.scheduledTasks,
|
||||
error: "",
|
||||
loading: true,
|
||||
},
|
||||
};
|
||||
@ -338,6 +337,7 @@ function tasksReducer(
|
||||
...state.scheduledTasks,
|
||||
loading: false,
|
||||
error: action.error,
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
|
||||
@ -346,7 +346,6 @@ function tasksReducer(
|
||||
...state,
|
||||
retryTasks: {
|
||||
...state.retryTasks,
|
||||
error: "",
|
||||
loading: true,
|
||||
},
|
||||
};
|
||||
@ -372,6 +371,7 @@ function tasksReducer(
|
||||
...state.retryTasks,
|
||||
loading: false,
|
||||
error: action.error,
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
|
||||
@ -380,7 +380,6 @@ function tasksReducer(
|
||||
...state,
|
||||
archivedTasks: {
|
||||
...state.archivedTasks,
|
||||
error: "",
|
||||
loading: true,
|
||||
},
|
||||
};
|
||||
@ -406,6 +405,7 @@ function tasksReducer(
|
||||
...state.archivedTasks,
|
||||
loading: false,
|
||||
error: action.error,
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
// toErrorString returns a string representaion of axios error.
|
||||
export function toErrorString(error: AxiosError<string>): string {
|
||||
// toErrorStringWithHttpStatus returns a string representaion of axios error with HTTP status.
|
||||
export function toErrorStringWithHttpStatus(error: AxiosError<string>): string {
|
||||
const { response } = error;
|
||||
if (!response) {
|
||||
return "error: no error response data available";
|
||||
@ -9,6 +9,15 @@ export function toErrorString(error: AxiosError<string>): string {
|
||||
return `${response.status} (${response.statusText}): ${response.data}`;
|
||||
}
|
||||
|
||||
// toErrorString returns a string representaion of axios error.
|
||||
export function toErrorString(error: AxiosError<string>): string {
|
||||
const { response } = error;
|
||||
if (!response) {
|
||||
return "Unknown error occurred. See the logs for details.";
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
|
||||
interface Duration {
|
||||
hour: number;
|
||||
minute: number;
|
||||
|
Loading…
Reference in New Issue
Block a user