Skip to content

Commit

Permalink
HPCC-32848 ECL Watch v9 display exceptions from /WsLogaccess/GetLogAc…
Browse files Browse the repository at this point in the history
…cessInfo

fixes an issue where any exceptions from /WsLogaccess/GetLogAccessInfo
were not being displayed in the UI

Signed-off-by: Jeremy Clements <[email protected]>
  • Loading branch information
jeclrsg committed Oct 23, 2024
1 parent 4a7afe3 commit 9a094c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
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);
});
}, []);
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;
});
}

0 comments on commit 9a094c9

Please sign in to comment.