Copilot commented on code in PR #774:
URL: 
https://github.com/apache/rocketmq-dashboard/pull/774#discussion_r3701460303


##########
web/src/pages/cluster/clients.tsx:
##########
@@ -75,6 +76,27 @@ const countBy = (values: string[]) =>
     .map(([label, count]) => ({ label, count }))
     .sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));
 
+type ApiErrorLike = {
+  message?: unknown;
+  response?: {
+    data?: {
+      message?: unknown;
+    };
+  };
+};
+
+function getLoadErrorMessage(error: unknown): 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 DEFAULT_LOAD_ERROR;
+}

Review Comment:
   `getLoadErrorMessage` assumes the caught value is an object and immediately 
reads `apiError.response...`. If the promise is rejected with 
`null`/`undefined` (or any non-object), this will throw inside the `catch`, 
preventing the page from rendering the intended empty state + warning.



-- 
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]

Reply via email to