# Can I display custom error messages when using a Custom DB?

**URL:** <https://community.auth0.com/t/can-i-display-custom-error-messages-when-using-a-custom-db/9276>\
**Category:** Get Help\
**Tags:** custom, custom-database\
**Created:** [January 24, 2018, 7:02am UTC](https://community.auth0.com/t/can-i-display-custom-error-messages-when-using-a-custom-db/9276 "2018-01-24T07:02:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guerin.riley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/guerin.riley/32/7620_2.png) [@guerin.riley](https://community.auth0.com/u/guerin.riley)\
**Post date:** [January 24, 2018, 7:02am UTC](https://community.auth0.com/t/can-i-display-custom-error-messages-when-using-a-custom-db/9276/1 "2018-01-24T07:02:29Z")

</div>

I’m using the following script for creating a user with the Custom DB feature (modified to remove URL). I am returning the correct error messages to the callback() function `callback('Email ' + body.errors.email);` but my users are only seeing

> WE’RE SORRY, SOMETHING WENT WRONG WHEN ATTEMPTING TO SIGN UP.  
> Is there any way I can show them the error messages? For example if email is taken, or password doesn’t match our policy.

```
function create (user, callback) {
  console.log(user);
  request.post({
    url: 'BASE_URL/users.json',
    json: true,
    body: {
      user: {
        email: user.email,
        password: user.password,
        password_confirmation: user.password
      }
    }
    //for more options check:
    //https://github.com/mikeal/request#requestoptions-callback
  }, function (err, response, body) {
    console.log("err", err);
    console.log("body", body);
    console.log("response.statusCode", response.statusCode);
    
    if (err) return callback(err);
    if (response.statusCode === 401) return callback();
    if (response.statusCode === 422 && body.errors) {
      if (body.errors.email) {
        callback('Email ' + body.errors.email);
      } else if (body.errors.password) {
        callback('Password ' + body.errors.password); 
      }
    }
    if (response.statusCode !== 201) return callback();
    
    console.log(body);
    
    callback(null, {
      user_id: body.id,
      email: body.email,
      nickname: body.email
    });

  });
}
```

---

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [February 20, 2018, 12:33am UTC](https://community.auth0.com/t/can-i-display-custom-error-messages-when-using-a-custom-db/9276/2 "2018-02-20T00:33:26Z")

</div>

In the event of an authorization error, you may choose to display either the default Auth0 error page or a customized error page to your users. You can check the following documentation for more detailed info:  
  
[Customize Error Pages](https://auth0.com/docs/hosted-pages/custom-error-pages)   
  
[Default Auth0 Error Page](https://auth0.com/docs/hosted-pages/error-pages)

---

<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:** [August 27, 2019, 10:36am UTC](https://community.auth0.com/t/can-i-display-custom-error-messages-when-using-a-custom-db/9276/3 "2019-08-27T10:36:40Z")

</div>

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