Copilot commented on code in PR #781:
URL:
https://github.com/apache/rocketmq-dashboard/pull/781#discussion_r3701519125
##########
web/src/pages/instance/dlq.tsx:
##########
@@ -39,9 +40,32 @@ import { listDLQGroups, resendDLQ } from
'../../services/messageService';
const { Text } = Typography;
const { RangePicker } = DatePicker;
+const DEFAULT_LOAD_ERROR = '死信队列加载失败,请稍后重试';
+const DEFAULT_RETRY_ERROR = '提交重投任务失败,请稍后重试';
/* ─── Helpers ─── */
+type ApiErrorLike = {
+ message?: unknown;
+ response?: {
+ data?: {
+ message?: unknown;
+ };
+ };
+};
+
+const getErrorMessage = (error: unknown, fallback: string): string => {
+ const apiError = error as ApiErrorLike;
+ const responseMessage = apiError.response?.data?.message;
+ if (typeof responseMessage === 'string' && responseMessage.trim()) {
+ return responseMessage;
+ }
+ if (typeof apiError.message === 'string' && apiError.message.trim()) {
+ return apiError.message;
+ }
+ return fallback;
+};
Review Comment:
`getErrorMessage` casts `error` to `ApiErrorLike` and then dereferences
`apiError.response` / `apiError.message` without guarding the base value. If
the promise is rejected with `null`, `undefined`, or a primitive (e.g.
`Promise.reject()`), this will throw a TypeError while trying to render the
error state, masking the original failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]