This commit is contained in:
Christian Owusu 2025-04-24 09:05:57 +00:00 committed by GitHub
commit 040f845d7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import { all_admin_roles } from "@/utils/roles";
import { message } from "antd";
import { TagNewRequest, TagUpdateRequest, TagDeleteRequest, TagInfoRequest, TagListResponse, TagInfoResponse } from "./tag_management/types";
import { Team } from "./key_team_helpers/key_list";
import { UiError } from "@/utils/errorUtils";
const isLocal = process.env.NODE_ENV === "development";
export const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
@ -3263,7 +3264,10 @@ export const teamMemberAddCall = async (
const errorData = await response.text();
handleError(errorData);
console.error("Error response from the server:", errorData);
throw new Error("Network response was not ok");
if (errorData.includes('already in team')) {
throw new UiError("User is already a member of this team")
}
throw new Error("Failed to add team member");
}
const data = await response.json();

View file

@ -33,6 +33,7 @@ import MemberModal from "./edit_membership";
import UserSearchModal from "@/components/common_components/user_search_modal";
import { getModelDisplayName } from "../key_team_helpers/fetch_available_models_team_key";
import { isAdminRole } from "@/utils/roles";
import { UiError } from "@/utils/errorUtils";
export interface TeamData {
team_id: string;
@ -131,7 +132,12 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
form.resetFields();
fetchTeamInfo();
} catch (error) {
message.error("Failed to add team member");
if (error instanceof UiError) {
message.error(error.message)
} else {
message.error("Failed to add team member");
}
console.error("Error adding team member:", error);
}
};

View file

@ -0,0 +1,6 @@
export class UiError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, UiError.prototype)
}
}