mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor(site): do not display error details as message (#9755)
This commit is contained in:
@@ -61,12 +61,7 @@ export const mapApiErrorToFieldErrors = (
|
||||
export const getErrorMessage = (
|
||||
error: unknown,
|
||||
defaultMessage: string,
|
||||
): string =>
|
||||
isApiError(error)
|
||||
? error.response.data.message
|
||||
: error instanceof Error
|
||||
? error.message
|
||||
: defaultMessage;
|
||||
): string => (isApiError(error) ? error.response.data.message : defaultMessage);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { action } from "@storybook/addon-actions";
|
||||
import { MockAuthMethods } from "testHelpers/entities";
|
||||
import { MockAuthMethods, mockApiError } from "testHelpers/entities";
|
||||
import { LoginPageView } from "./LoginPageView";
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
|
||||
@@ -24,14 +24,15 @@ export const Example: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
const err = new Error("Username or email are wrong.");
|
||||
|
||||
export const AuthError: Story = {
|
||||
args: {
|
||||
isLoading: false,
|
||||
onSignIn: action("onSignIn"),
|
||||
context: {
|
||||
error: err,
|
||||
error: mockApiError({
|
||||
message: "User or password is incorrect",
|
||||
detail: "Please, try again",
|
||||
}),
|
||||
data: {
|
||||
authMethods: MockAuthMethods,
|
||||
hasFirstUser: false,
|
||||
|
||||
Reference in New Issue
Block a user