I use the Pre sign-up trigger of Cognito to validate the user registration. If some validation fails the function responses with a custom error. The client only receive the UserLambdaValidationException as ErrorCode.
Is there a way to receive the custom error name instead?
Current using sample:
exports.handler = function(event, context, callback) {
function AccountAlreadyExistsError(message) {
this.name = "AccountAlreadyExistsError";
this.message = message;
}
AccountAlreadyExistsError.prototype = new Error();
const error = new AccountAlreadyExistsError("Account is in use!");
callback(error);
};
I want to get AccountAlreadyExistsError in our client instead of UserLambdaValidationException.