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

HPCC-32848 ECL Watch v9 display exceptions from GetLogAccessInfo #19226

Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions esp/src/src-react/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ export const SubNavigation: React.FunctionComponent<SubNavigationProps> = ({
React.useEffect(() => {
hasLogAccess().then(response => {
setLogsDisabled(!response);
}).catch(() => {
setLogsDisabled(true);
Comment on lines -301 to -302
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this in the review a while back I think. But this catch and the one removed in WorkunitDetails are unreachable aren't they? Because of the catch in hasLogAccess (around line 56/57 in ESPLog.ts)

});
}, []);
const linkStyle = React.useCallback((disabled) => {
Expand Down
3 changes: 0 additions & 3 deletions esp/src/src-react/components/WorkunitDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ export const WorkunitDetails: React.FunctionComponent<WorkunitDetailsProps> = ({
hasLogAccess().then(response => {
setLogsDisabled(!response);
return response;
}).catch(err => {
logger.warning(err);
setLogsDisabled(true);
});
}, [wuid], [queryParams]);

Expand Down
20 changes: 16 additions & 4 deletions esp/src/src/ESPLog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogaccessService, LogLine, GetLogsExRequest, WsLogaccess } from "@hpcc-js/comms";
import { LogaccessService, LogLine, GetLogsExRequest, WsLogaccess, Exceptions } from "@hpcc-js/comms";
import { scopedLogger } from "@hpcc-js/util";
import * as Observable from "dojo/store/Observable";
import { Paged } from "./store/Paged";
Expand All @@ -8,8 +8,12 @@ const logger = scopedLogger("src/ESPLog.ts");

export const service = new LogaccessService({ baseUrl: "" });

let g_logAccessInfo: Promise<WsLogaccess.GetLogAccessInfoResponse>;
export function GetLogAccessInfo(): Promise<WsLogaccess.GetLogAccessInfoResponse> {
function isExceptionResponse(response: WsLogaccess.GetLogAccessInfoResponse | { Exceptions?: Exceptions }): response is { Exceptions?: Exceptions } {
return (response as { Exceptions?: Exceptions }).Exceptions !== undefined;
}

let g_logAccessInfo: Promise<WsLogaccess.GetLogAccessInfoResponse | { Exceptions?: Exceptions }>;
export function GetLogAccessInfo(): Promise<WsLogaccess.GetLogAccessInfoResponse | { Exceptions?: Exceptions }> {
if (!g_logAccessInfo) {
g_logAccessInfo = service.GetLogAccessInfo({});
}
Expand Down Expand Up @@ -41,8 +45,16 @@ export function CreateLogsQueryStore<T extends GetLogsExRequest>(): LogsQuerySto

export function hasLogAccess(): Promise<boolean> {
return GetLogAccessInfo().then(response => {
return response.RemoteLogManagerConnectionString !== null || response.RemoteLogManagerType !== null;
if (isExceptionResponse(response)) {
const err = response.Exceptions.Exception[0].Message;
logger.error(err);
return false;
} else {
response = response as WsLogaccess.GetLogAccessInfoResponse;
return response?.RemoteLogManagerConnectionString !== null || response?.RemoteLogManagerType !== null;
}
}).catch(e => {
logger.error(e);
return false;
});
}
Loading