# Universal Login page not showing friendly error message

**URL:** <https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004>\
**Category:** Get Help\
**Tags:** extensibility, actions-extensibility\
**Created:** [August 19, 2023, 3:44am UTC](https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004 "2023-08-19T03:44:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodrigo.bernardino](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rodrigo.bernardino/32/49477_2.png) [@rodrigo.bernardino](https://community.auth0.com/u/rodrigo.bernardino)\
**Post date:** [August 19, 2023, 3:44am UTC](https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004/1 "2023-08-19T03:44:30Z")

</div>

I created a Pre User Registration action to create the new user in my app external database during the user signup and I have configured a few friendly error messages to improve UX:

```auto
const axios = require("axios")

/**
* Handler that will be called during the execution of a PreUserRegistration flow.
*
* @param {Event} event - Details about the context and user that is attempting to register.
* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.
*/
exports.onExecutePreUserRegistration = async (event, api) => {
  const newBaseUser = {
    email: event.user.email,
    name: event.user.name,
    picture_uri: event.user.picture
  };

  const response = await axios.post(`${event.secrets.ELVIE_API_URL}/api/users/create-user`, newBaseUser, {
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": event.secrets.ELVIE_API_KEY
    } 
  });

  if (response.status === 403) {
    api.access.deny("forbidden_api_access", "Forbidden access to the Elvie API. Please check if the API Key header is being sent.");
  }
  else if (response.status === 401) {
    api.access.deny("unauthorized_api_access", "Unauthorized access to the Elvie API. Please check if the API Key header is valid.");
  }
  else if (response.status === 400) {
    api.access.deny("user_already_exists", "An user with the specified email already exists");
  }
  else if (response.status !== 200) {
    api.access.deny("api_internal_error", "Elvie API internal error");
  }
};

```

However, when an error occurs, I’m getting an generic `Extensibility error` message:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/7/a7e7cac6d88f26d49c47cce821cf614b0e9c214c.png)

The pre-user-registration API object documentation states that the `userMessage` **may** be presented directly in end-user interfaces. How can I make sure that the custom `userMessage` will be presented in my end-user interface?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 23, 2023, 2:26pm UTC](https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004/3 "2023-08-23T14:26:26Z")

</div>

Hi @rodrigo.bernardino,

If everything was working correctly, I would expect to see the string in one of the userMessages displayed in the signup prompt. I suspect something else in your pre-user registration action is throwing an error and causing the ‘extensibility error’ message.

---

<div class="post-metadata">

**Author:** ![rodrigo.bernardino](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rodrigo.bernardino/32/49477_2.png) [@rodrigo.bernardino](https://community.auth0.com/u/rodrigo.bernardino)\
**Post date:** [August 29, 2023, 2:09am UTC](https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004/4 "2023-08-29T02:09:04Z")

</div>

You were correct, my action was not catching the axios error response correctly. This is the updated code:

```auto
const axios = require("axios")

/**
* Handler that will be called during the execution of a PreUserRegistration flow.
*
* @param {Event} event - Details about the context and user that is attempting to register.
* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.
*/
exports.onExecutePreUserRegistration = async (event, api) => {
  const newBaseUser = {
    email: event.user.email,
    name: event.user.username,
    picture_uri: event.user.picture
  };
  try {
    await axios.post(`${event.secrets.ELVIE_API_URL}/api/users/create-user`, newBaseUser, {
      headers: {
        "Content-Type": "application/json",
        "X-API-Key": event.secrets.ELVIE_API_KEY
      } 
    });
  } catch (error) {
    if (error.response.status === 403) {
      api.access.deny("forbidden_api_access", "Forbidden access to the Elvie API. Please check if the API Key header is being sent.");
    }
    else if (error.response.status === 401) {
      api.access.deny("unauthorized_api_access", "Unauthorized access to the Elvie API. Please check if the API Key header is valid.");
    }
    else if (error.response.status === 400) {
      api.access.deny("user_already_exists", "An user with the specified email already exists");
    }
    else if (error.response.status !== 200) {
      api.access.deny("api_internal_error", "Elvie API internal error");
    }
  }
};

```

Also, I disabled this setting to have a full support for readable error messages during signup:  
_Tenant Settings → Advanced → Use a generic response in public signup API error message_

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 29, 2023, 3:08pm UTC](https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004/5 "2023-08-29T15:08:01Z")

</div>

Great, thanks for posting an update!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 12, 2023, 3:08pm UTC](https://community.auth0.com/t/universal-login-page-not-showing-friendly-error-message/114004/6 "2023-09-12T15:08:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
