Skip to content
Last updated

Backend error

BackendError is a type that represents an error that is returned from the backend in response to an action.

Properties

type BackendError = InvalidEmailError | UnknownError;

type InvalidEmailError

InvalidEmailError happens particularly when the user tries to identify themselves with an invalid email address. Also, when you call _dixa_.invoke("setUserIdentity", {...payload}) with an invalid email address.

Properties

type InvalidEmailError = {
  type: 'invalid-email-address';
  email: string;
};

You can add an event listener to listen to this error before setting the user identity.

// First add the listener
_dixa_.addListener('on-backend-error', (error) => {
  if (error.type === 'invalid-email-address') {
    console.error(`${error.email} is not a valid email address`);
  }
});

// Then call the method
_dixa_.invoke('setUserIdentity', {
  type: 'claim',
  name: 'John Doe',
  email: 'invalid-email',
});

type UnknownError

Properties

type UnknownError = {
  type: 'unknown-error';
};

UnknownError happens when the backend returns an error that is not known to the widget.