refactor(site): do not display error details as message (#9755)

This commit is contained in:
Bruno Quaresma
2023-09-19 09:54:59 -03:00
committed by GitHub
parent e26bb2d91b
commit 7bc98c296b
2 changed files with 6 additions and 10 deletions
+1 -6
View File
@@ -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,