Is there a way to customize the error message for ...
# ask-a-descoper
i
Is there a way to customize the error message for the sign-in flow? 1. I want to be able to show my own message when login fails 2. trying to register a callback for the
onError
prop, doesn't get invoked when the login fails. (when is it triggered?) 3. i couldn't see other callbacks on the React SDK (https://github.com/descope/react-sdk/blob/583820e9bbc6df0442c14b3512a26b071869a123/src/components/Descope.tsx) Am i missing something? or is it not possible to do?
g
hi @important-river-90900 that’s true - currently all errors are handled by Descope. you can make sure those are viewable by your end users using the ‘error message’ component. that component is dynamic and presents the relevant error upon trigger. so for example - the same error message component can present an error gotten from magic link but also from sso 🙂 do you feel like our existing errors are not indicative enough? which error string do you want to update?
i
thanks. i'd like to be able to control 3 things: 1. the design of this error message 2. the error message itself. In my case for example, i am using the SignInFlow component and using only the SSO option. the error message for example for a blank email in the input gives:
None of the following inputs where provided to SSO login: Email, Tenant Name or Tenant ID.
tenant name or tenant ID are irrelevant info for the end user. they only have to put in an e-mail. so this is confusing. 3. I also want to be able to log this error message to my DB to get visibility on issues around login. But the
onError
callback doesn't get triggered. It's a problem
g
regarding 1 and 2 - i understand now, i want to check a few options on what can be done and get back to you regarding 3 - the
onError
callback gets triggered if the flow ended. in this case, because the flow ‘handled the error on itself’ and technically the user can continue to a ‘successful path’ in the flow - it doesn’t count as an end. but the feedback in general is good - i’ll raise this one 🙏🏼
👍 1
i
i want to be able to know that users couldn't log in, and which users those were. super important.
thanks for helping. i'm looking forward to your answers on all 3
q
Hi @important-river-90900 wanted to let you know that we just added
errorTransformer
to our
react-sdk
You are now able to pass a function that gets an error object and return a string to the end user, for example:
Copy code
const errorTransformer = useCallback(
	(error: { text: string; type: string }) => {
		const translationMap = {
			SAMLStartFailed: 'Failed to start SAML flow'
		};
		return translationMap[error.type] || error.text;
	},
	[]
);
...
	<Descope
		...
		errorTransformer={errorTransformer}
 	/>
You can get it by using the
next
version (
0.0.0-next-8d715fcd-20230709
) Please LMK if anything further is needed for this
👍 1