Skip to content
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
5 changes: 4 additions & 1 deletion core/app/api/customer/groups/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export async function GET(): Promise<NextResponse> {
);

if (!response.ok) {
throw new Error(`Failed to fetch customer groups: ${response.statusText}`);
// eslint-disable-next-line no-console
console.error(`Failed to fetch customer groups: ${response.status} ${response.statusText}`);

return NextResponse.json(null, { status: 500 });
}

// `/v2/customer_groups` endpoint returns a `204 No Content` response if there are no customer groups
Expand Down
7 changes: 3 additions & 4 deletions core/b2b/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ export async function loginWithB2B({ customerId, customerAccessToken }: LoginWit
if (!response.ok) {
const errorMessage = ErrorResponse.parse(await response.json()).detail;

// Use the resolved `apiHost` variable in the error message for accuracy
throw new Error(
`Failed to login with ${apiHost}. Status: ${response.status}, Message: ${errorMessage}`
);
// eslint-disable-next-line no-console
console.error(`B2B login failed. Host: ${apiHost}, Status: ${response.status}, Message: ${errorMessage}`);
throw new Error('Failed to authenticate with B2B API.');
}

return B2BTokenResponseSchema.parse(await response.json()).data.token[0];
Expand Down
2 changes: 1 addition & 1 deletion core/b2b/server-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const login = async (email: string, password: string) => {
console.error(error);

if (error instanceof BigCommerceGQLError) {
return error.errors.map(({ message }) => message).join(', ');
return t('somethingWentWrong');
}

if (
Expand Down
7 changes: 6 additions & 1 deletion core/client/queries/get-customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export async function getCustomerGroupId() {
});

if (errors) {
throw new Error(errors.map((error) => error.message).join(', '));
// eslint-disable-next-line no-console
console.error(
'Failed to fetch customer group:',
errors.map((error) => error.message).join(', '),
);
throw new Error('Failed to fetch customer group.');
}

return { data };
Expand Down
Loading