Skip to content

Commit

Permalink
feat: mvp for an updated store
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon committed Sep 30, 2024
1 parent 0371b57 commit 30daeed
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 162 deletions.
5 changes: 2 additions & 3 deletions src/components/PipelinesCopy/PipelineUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ const PipelineUpload = ({
try {
await handleInstallPlugin(nonAdminCredentials, selectedPlugin);
} catch (e) {
if (axios.isAxiosError(e)) {
throw new Error(e.response?.data);
}
// biome-ignore lint/complexity/noUselessCatch: <explanation>
throw e;
}
};

Expand Down
19 changes: 15 additions & 4 deletions src/components/PipelinesCopy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export const handleInstallPlugin = async (
version: pluginToInstall.data.version,
plugin_store_url: pluginToInstall.url,
};

try {
const response = await axios.post(adminURL, pluginData, {
headers: {
Expand All @@ -116,9 +115,21 @@ export const handleInstallPlugin = async (
const data = await response.data;
return data;
} catch (e) {
if (axios.isAxiosError(e)) {
const message = e.response?.data || e.message;
return message;
console.log("Error", e);
if (axios.isAxiosError(e) && e.response?.data) {
const message = e.response.data;

// Log the entire error for more detailed context
console.error("Full error response:", message);

// Check if it's an object with errors
if (typeof message === "object") {
const firstErrorKey = Object.keys(message)[0]; // Get the first error key
const firstErrorMessage = message[firstErrorKey][0]; // Get the first error message
throw new Error(`${firstErrorMessage}`);
}
} else {
throw new Error("An unexpected error occurred");
}
}
};
Expand Down
Loading

0 comments on commit 30daeed

Please sign in to comment.