Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Move callingFn from string literals to a shared const #3770

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/layouts/BaseLayout/hooks/NavigatorDataQueryOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ export const NavigatorDataQueryOpts = ({
repo,
},
}).then((res) => {
const callingFn = 'NavigatorDataQueryOpts'
const parsedData = RequestSchema.safeParse(res.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'NavigatorDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ export const useUpdateOktaConfig = ({ provider, owner }: URLParams) => {
})
},
onSuccess: ({ data }) => {
const callingFn = 'useUpdateOktaConfig'
const parsedData = ResponseSchema.safeParse(data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useUpdateOktaConfig',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ export function OktaConfigQueryOpts({
username,
},
}).then((res) => {
const callingFn = 'OktaConfigQueryOpts'
const parsedRes = OktaConfigRequestSchema.safeParse(res?.data)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'OktaConfigQueryOpts',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@ export const useSetUploadTokenRequired = ({
},
mutationPath: 'setUploadTokenRequired',
}).then((res) => {
const callingFn = 'useSetUploadTokenRequired'
const parsedData = ResponseSchema.safeParse(res.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useSetUploadTokenRequired',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ export const useAdminAccessList = () => {
path: `/users?is_admin=true&page=${pageParam}`,
signal,
}).then((res) => {
const callingFn = 'useAdminAccessList'
const parsedData = RequestSchema.safeParse(res)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useAdminAccessList',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}
return parsedData.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ export const CommitHeaderDataQueryOpts = ({
commitId,
},
}).then((res) => {
const callingFn = 'CommitHeaderDataQueryOpts'
const parsedData = CommitHeaderDataSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'CommitHeaderDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand All @@ -121,14 +119,14 @@ export const CommitHeaderDataQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'CommitHeaderDataQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'CommitHeaderDataQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,13 @@ export const CommitHeaderDataTeamQueryOpts = ({
commitId,
},
}).then((res) => {
const callingFn = 'CommitHeaderDataTeamQueryOpts'
const parsedData = CommitHeaderDataTeamSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'CommitHeaderDataTeamQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand All @@ -180,14 +178,14 @@ export const CommitHeaderDataTeamQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'CommitHeaderDataTeamQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'CommitHeaderDataTeamQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Expand Down
10 changes: 4 additions & 6 deletions src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,13 @@ export const CommitPageDataQueryOpts = ({
commitId,
},
}).then((res) => {
const callingFn = 'CommitPageDataQueryOpts'
const parsedData = CommitPageDataSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'CommitPageDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand All @@ -174,14 +172,14 @@ export const CommitPageDataQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'CommitPageDataQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'CommitPageDataQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Expand Down
6 changes: 2 additions & 4 deletions src/pages/PlanPage/queries/PlanPageDataQueryOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ export function PlanPageDataQueryOpts({
variables,
signal,
}).then((res) => {
const callingFn = 'PlanPageDataQueryOpts'
const parsedRes = RequestSchema.safeParse(res?.data)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'PlanPageDataQueryOpts',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@ export function EnterpriseAccountDetailsQueryOpts({
owner,
},
}).then((res) => {
const callingFn = 'EnterpriseAccountDetailsQueryOpts'
const parsedRes = EnterpriseAccountDetailsRequestSchema.safeParse(
res?.data
)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'EnterpriseAccountDetailsQueryOpts',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ export function InfiniteAccountOrganizationsQueryOpts({
after,
},
}).then((res) => {
const callingFn = 'InfiniteAccountOrganizationsQueryOpts'
const parsedRes = RequestSchema.safeParse(res.data)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'InfiniteAccountOrganizationsQueryOpts',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Expand All @@ -115,9 +113,7 @@ export function InfiniteAccountOrganizationsQueryOpts({
if (!account) {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: {
callingFn: 'InfiniteAccountOrganizationsQueryOpts',
},
errorDetails: { callingFn },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ export const useCurrentOrgPlanPageData = ({
owner,
},
}).then((res) => {
const callingFn = 'useCurrentOrgPlanPageData'
const parsedRes = CurrentOrgPlanPageDataSchema.safeParse(res?.data)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'useCurrentOrgPlanPageData',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,13 @@ export const PullHeadDataQueryOpts = ({
pullId: parseInt(pullId, 10),
},
}).then((res) => {
const callingFn = 'PullHeadDataQueryOpts'
const parsedData = PullHeadDataSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'PullHeadDataQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand All @@ -125,14 +123,14 @@ export const PullHeadDataQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'PullHeadDataQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'PullHeadDataQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ export const PullHeadDataTeamQueryOpts = ({
pullId: parseInt(pullId, 10),
},
}).then((res) => {
const callingFn = 'PullHeadDataTeamQueryOpts'
const parsedData = PullHeadDataSchema.safeParse(res?.data)

if (!parsedData.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'PullHeadDataTeamQueryOpts',
error: parsedData.error,
},
errorDetails: { callingFn, error: parsedData.error },
})
}

Expand All @@ -177,14 +175,14 @@ export const PullHeadDataTeamQueryOpts = ({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'PullHeadDataTeamQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'PullHeadDataTeamQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,13 @@ export function ComponentComparisonQueryOpts({
pullId: parseInt(pullId, 10),
},
}).then((res) => {
const callingFn = 'ComponentComparisonQueryOpts'
const parsedRes = ComponentComparisonSchema.safeParse(res?.data)

if (!parsedRes.success) {
return rejectNetworkError({
errorName: 'Parsing Error',
errorDetails: {
callingFn: 'ComponentComparisonQueryOpts',
error: parsedRes.error,
},
errorDetails: { callingFn, error: parsedRes.error },
})
}

Expand All @@ -189,14 +187,14 @@ export function ComponentComparisonQueryOpts({
if (data?.owner?.repository?.__typename === 'NotFoundError') {
return rejectNetworkError({
errorName: 'Not Found Error',
errorDetails: { callingFn: 'ComponentComparisonQueryOpts' },
errorDetails: { callingFn },
})
}

if (data?.owner?.repository?.__typename === 'OwnerNotActivatedError') {
return rejectNetworkError({
errorName: 'Owner Not Activated',
errorDetails: { callingFn: 'ComponentComparisonQueryOpts' },
errorDetails: { callingFn },
data: {
detail: (
<p>
Expand Down
Loading
Loading