Skip to content

Commit

Permalink
AAP-19344: add data types for errors in catch block (#786)
Browse files Browse the repository at this point in the history
* AAP-19344: add data types for errors in catch block
  • Loading branch information
hasys authored Jan 18, 2024
1 parent c682fd0 commit c798c22
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions ansible_wisdom_console_react/src/ModelSettingsKey.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AxiosError } from "axios";
import React, { useCallback, useMemo, useState } from "react";
import "./ModelSettings.css";
import { WcaKey, WcaKeyRequest } from "./api/types";
import { APIException, WcaKey, WcaKeyRequest } from "./api/types";
import { saveWcaKey } from "./api/api";
import { HasError, NO_ERROR } from "./ErrorModal";
import { DELAY } from "./api/globals";
Expand Down Expand Up @@ -29,14 +30,14 @@ export const ModelSettingsKey = (props: ModelSettingsKeyProps) => {
.then((_) => {
reload();
})
.catch((error) => {
.catch((error: AxiosError<APIException, any>) => {
if (error.response?.status === 400) {
setIsKeyInvalid(true);
} else {
setKeyError({
inError: true,
message: error.message,
detail: error.response?.data?.detail,
detail: error.response?.data?.detail ?? "",
});
}
})
Expand Down
7 changes: 4 additions & 3 deletions ansible_wisdom_console_react/src/ModelSettingsModelId.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AxiosError } from "axios";
import React, { useCallback, useMemo, useState } from "react";
import "./ModelSettings.css";
import { WcaModelId, WcaModelIdRequest } from "./api/types";
import { APIException, WcaModelId, WcaModelIdRequest } from "./api/types";
import { saveWcaModelId } from "./api/api";
import { HasError, NO_ERROR } from "./ErrorModal";
import { DELAY } from "./api/globals";
Expand Down Expand Up @@ -32,14 +33,14 @@ export const ModelSettingsModelId = (props: ModelSettingsModelIdProps) => {
.then((_) => {
reload();
})
.catch((error) => {
.catch((error: AxiosError<APIException, any>) => {
if (error.response?.status === 400) {
setIsModelIdInvalid(true);
} else {
setModelIdError({
inError: true,
message: error.message,
detail: error.response?.data?.detail,
detail: error.response?.data?.detail ?? "",
});
}
})
Expand Down
4 changes: 2 additions & 2 deletions ansible_wisdom_console_react/src/ModelSettingsOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ export const ModelSettingsOverview = (props: ModelSettingsOverviewProps) => {
.then((_) => {
alertsRef.current?.addAlert(t("KeyValidationSuccess"));
})
.catch((error) => {
.catch((error: AxiosError<APIException, any>) => {
if (error.response?.status === 400) {
setIsKeyInvalid(true);
} else {
setKeyError({
inError: true,
message: error.message,
detail: error.response?.data?.detail,
detail: error.response?.data?.detail ?? "",
});
}
})
Expand Down
6 changes: 4 additions & 2 deletions ansible_wisdom_console_react/src/TelemetrySettings.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AxiosError } from "axios";
import React, {
useCallback,
useEffect,
Expand Down Expand Up @@ -25,6 +26,7 @@ import {
} from "@patternfly/react-core";
import "./ModelSettings.css";
import {
APIException,
Success,
Telemetry,
TelemetryRequest,
Expand Down Expand Up @@ -94,11 +96,11 @@ export function TelemetrySettings() {
alertsRef.current?.addAlert(t("TelemetryOptInSaveSuccessAlert"));
}
})
.catch((error) => {
.catch((error: AxiosError<APIException, any>) => {
setTelemetrySettingsError({
inError: true,
message: error.message,
detail: error.response?.data?.detail,
detail: error.response?.data?.detail ?? "",
});
})
.finally(() => {
Expand Down

1 comment on commit c798c22

@github-actions
Copy link

Choose a reason for hiding this comment

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

ClamAV Virus Definition DB Files:
----
total 227948
-rw-r--r--  1 root root 170479789 Jan 18 06:07 main.cvd
-rw-r--r--  1 root root        69 Jan 18 06:07 freshclam.dat
-rw-r--r--  1 root root  62626072 Jan 18 06:07 daily.cvd
-rw-r--r--  1 root root    291965 Jan 18 06:07 bytecode.cvd
drwxr-xr-x 16 root root      4096 Jan 18 14:14 ..
drwxr-xr-x  2 root root      4096 Jan 18 14:14 .
----
File: /var/lib/clamav/bytecode.cvd
Build time: 22 Feb 2023 16:33 -0500
Version: 334
Signatures: 91
Functionality level: 90
Builder: anvilleg
MD5: 0464067a252b1e937012ad34e811065f
Digital signature: urVBCbhJcz8v6i1E6HedDwa8TxBHnJknqg7SE+6JWBtovATpw8MWwS+kvGAi//x5u0LIFwhPvUsgEBBeFiZE0QTTWazOhJ/LfKJK+nODqha6cTvaQdKl2rSbEOv6grv7UONV8eKi383Wv07wfSNYp+lPNpt0QmejKb1TMHAYTA
Verification OK.
----
File: /var/lib/clamav/daily.cvd
Build time: 17 Jan 2024 04:41 -0500
Version: 27157
Signatures: 2051049
Functionality level: 90
Builder: raynman
MD5: b02c83d51a5b76730c48a380e0c6bb48
Digital signature: F7d6p6NT3wW6ZjzJoMQYB3g1JnzzdT9cqua7tRDxSeL3eO5qfcv0/K7CzIlRtiCORQxAhAvwhc+WzSh/hh+KQriuG2LA9HaB0BFkmBKYEMUQtkJGpyOvyFE1ONR6WE0JBVAnhfQjIWipR8rF81ZOJL0pMHnjlVE6Y83BcjQ4fhb
Verification OK.
----
File: /var/lib/clamav/main.cvd
Build time: 16 Sep 2021 08:32 -0400
Version: 62
Signatures: 6647427
Functionality level: 90
Builder: sigmgr
MD5: 137eccce31aacb21b5a98bb8c21cefd6
Digital signature: twaJBls8V5q64R7QY10AatEtPNuPWoVoxTaNO1jpBg7s5jIMMXpitgG1000YLp6rb0TWkEKjRqxneGTxuxWaWm7XBjsgwX2BRWh/y4fhs7uyImdKRLzQ5y8e2EkSChegF/i8clqfn+1qetq9j4gbktJ3JZpOXPoHlyr2Dv9S/Bg
Verification OK.
----
Scanning Results:
ClamAV 1.0.4/27157/Wed Jan 17 09:41:11 2024
LibClamAV Warning: Max file-size was set to 4194304000 bytes. Unfortunately, scanning files greater than 2147483647 bytes (2 GiB - 1) is not supported.

----------- SCAN SUMMARY -----------
Known viruses: 8682920
Engine version: 1.0.4
Scanned directories: 30949
Scanned files: 190131
Infected files: 0
Data scanned: 6494.96 MB
Data read: 3410.44 MB (ratio 1.90:1)
Time: 2179.401 sec (36 m 19 s)
Start Date: 2024:01:18 14:16:54
End Date:   2024:01:18 14:53:13

Please sign in to comment.