Custom Database Login Script not Displaying Errors

Problem statement

Errors from a custom database login script are not displayed to the end user in the front end.

Cause

The Error() constructor does not return the custom error message to the front end.

Solution

The following constructors communicate errors back from custom databases to the front end. Use these constructors:

new UnauthorizedError(<message>)
Description: Occurs when something went wrong while trying to reach the database. Preferred way of communicating errors back from custom databases to front-end.

new WrongUsernameOrPasswordError(<email or user_id>, <message>)
Description: Occurs when the user’s credentials are invalid.a