mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
For #25201. <img width="435" alt="image" src="https://github.com/user-attachments/assets/c499902b-d461-4621-b2fc-7cb845ce71c4" /> # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated automated tests - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import React from "react";
|
|
import { isAxiosError } from "axios";
|
|
|
|
import { getErrorReason } from "interfaces/errors";
|
|
import { LEARN_MORE_ABOUT_BASE_LINK } from "utilities/constants";
|
|
|
|
import CustomLink from "components/CustomLink";
|
|
|
|
import { generateSecretErrMsg } from "pages/SoftwarePage/helpers";
|
|
|
|
const DEFAULT_ERROR_MESSAGE = "Couldn't add. Please try again.";
|
|
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export const getErrorMessage = (err: unknown) => {
|
|
const isTimeout =
|
|
isAxiosError(err) &&
|
|
(err.response?.status === 504 || err.response?.status === 408);
|
|
const reason = getErrorReason(err);
|
|
|
|
if (isTimeout) {
|
|
return "Couldn't upload. Request timeout. Please make sure your server and load balancer timeout is long enough.";
|
|
} else if (reason.includes("Secret variable")) {
|
|
return generateSecretErrMsg(err);
|
|
} else if (reason.includes("Unable to extract necessary metadata")) {
|
|
return (
|
|
<>
|
|
Couldn't add. Unable to extract necessary metadata.{" "}
|
|
<CustomLink
|
|
url={`${LEARN_MORE_ABOUT_BASE_LINK}/package-metadata-extraction`}
|
|
text="Learn more"
|
|
newTab
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
return reason || DEFAULT_ERROR_MESSAGE;
|
|
};
|