> For the complete documentation index, see [llms.txt](https://bayun.gitbook.io/bayuncoresdk-javascript-programming-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bayun.gitbook.io/bayuncoresdk-javascript-programming-guide/bayun-errors.md).

# 9. Bayun Errors

Following are the errors thrown by the Bayun SDK, along with a description for each error.

### How to consume Bayun errors

Bayun SDK APIs fail with a **BayunError code** (a string constant). The SDK also exposes **`BayunErrorUserMessages`** — ready-made user-facing messages keyed by those codes.

Use this simplest pattern in your app (same approach as the WebRTC sample):

```javascript
const BayunError = BayunCore.BayunError;
const BayunErrorUserMessages = BayunCore.BayunErrorUserMessages;

function displayBayunError(error) {
  const message =
    BayunErrorUserMessages[error] ||
    BayunErrorUserMessages[BayunError.ERROR_SOMETHING_WENT_WRONG] ||
    "Something Went Wrong";

  window.alert(message); // replace with toast / your UI
}
```

Call it from any failure path:

```javascript
// Callback-style API
bayunCore.loginWithPassword(
  sessionId,
  companyName,
  companyEmployeeId,
  password,
  autoCreateEmployee,
  securityQuestionsAnswers,
  successCallback,
  (error) => {
    displayBayunError(error);
  }
);

// Promise / async-await
try {
  await bayunCore.lockText(text, encryptionPolicy, keyGenerationPolicy);
} catch (error) {
  displayBayunError(error);
}
```

#### Optional: override messages for your product wording

```javascript
const BayunErrorUserMessageOverrides = {
  [BayunError.ERROR_GROUP_DOES_NOT_EXIST]:
    "Room does not exist, or you are not added to this room.",
  [BayunError.ERROR_MEMBER_DOESNT_BELONG_TO_GROUP]:
    "You are not a member of this room.",
};

function displayBayunError(error) {
  window.alert(
    BayunErrorUserMessageOverrides[error] ||
      BayunErrorUserMessages[error] ||
      BayunErrorUserMessages[BayunError.ERROR_SOMETHING_WENT_WRONG] ||
      "Something Went Wrong"
  );
}
```

#### Branch on a specific error

```javascript
if (error === BayunError.ERROR_REAUTHENTICATION_NEEDED) {
  // Session expired — send the user back to login
  redirectToLogin();
  return;
}

displayBayunError(error);
```

{% hint style="info" %}
`BayunError` and `BayunErrorUserMessages` are available on `BayunCore` after you load the Bayun JavaScript SDK (`window.BayunCore`).
{% endhint %}

**Authentication and Access Errors**

* **ERROR\_ACCESS\_DENIED** **:** If user access is denied (authentication token expires) or if user does not have right to perform certain operation. Library returns `BayunErrorAccessDenied`.
* **ERROR\_AUTHENTICATION\_FAILED** **:** If user authentication fails. Library returns `BayunErrorAuthenticationFailed`.
* **ERROR\_REAUTHENTICATION\_NEEDED** **:** If it is needed for the user to be authenticated again. Library returns `BayunErrorReauthenticationNeeded`.
* **ERROR\_USER\_IS\_NOT\_REGISTERED** **:** If user is not registered and login is attempted. Library returns `BayunErrorUserIsNotRegistered`.
* **ERROR\_LINK\_USER\_MEMBER\_ON\_ADMIN** **:** User and member exist; login on admin panel with user to link user and member. Library returns `BayunErrorLinkUserMemberOnAdmin`.
* **ERROR\_MEMBER\_APP\_NOT\_APPROVED** **:** If this application is not approved, please contact your admin to approve the application. Library returns `BayunErrorMemberAppNotApproved`.
* **ERROR\_REGISTRATION\_FAILED\_APPLICATION\_IS\_NOT\_APPROVED** **:** Registration failed because the application is not approved. Please contact your admin for the application approval. Library returns `BayunErrorRegistrationFailedApplicationIsNotApproved`.
* **RE\_REGISTER** **:** If re-registration is needed. Library returns `BayunErrorReRegister`.
* **USER\_REGISTRATION\_PENDING** **:** If user registration is pending. Library returns `BayunErrorUserRegistrationPending`.

**Credential and Verification Errors**

* **ERROR\_INVALID\_CREDENTIALS** **:** If credentials are invalid. Library returns `BayunErrorInvalidCredentials`.
* **ERROR\_CREDENTIALS\_CANNOT\_BE\_NULL** **:** If credentials for authentication are null. Library returns `BayunErrorCredentialsCannotBeNull`.
* **ERROR\_INVALID\_PASSPHRASE** **:** If passphrase is invalid. Library returns `BayunErrorInvalidPassphrase`.
* **ERROR\_PASSPHRASE\_CANNOT\_BE\_NULL** **:** If passphrase for validation is null. Library returns `BayunErrorPassphraseCannotBeNull`.
* **ERROR\_INVALID\_PASSCODE** **:** If passcode is invalid. Library returns `BayunErrorInvalidPasscode`.
* **ERROR\_NULL\_PASSCODE** **:** If passcode is null. Library returns `BayunErrorNullPasscode`.
* **ERROR\_USER\_PASSCODE\_VERIFICATION\_ENABLED** **:** If the user being used to register a new member has passcode verification enabled. Library returns `BayunErrorUserPasscodeVerificationEnabled`.
* **ERROR\_MEMBER\_VERIFICATION\_FAILED** **:** If the verification fails for any of the keys of the member. Library returns `BayunErrorMemberVerificationFailed`.
* **ERROR\_DEVELOPER\_KEY\_VERIFICATION\_FAILED** **:** If the developer key verification fails. Library returns `BayunErrorDeveloperKeyVerificationFailed`.
* **ERROR\_SERVER\_VERIFICATION\_FAILED** **:** If server verification fails. Library returns `BayunErrorServerVerificationFailed`.
* **ERROR\_INVALID\_SERVER\_PUBLIC\_KEY** **:** If the server public key is invalid. Library returns `BayunErrorInvalidServerPublicKey`.

**Encryption, Decryption, and Cryptographic Errors**

* **ERROR\_ENCRYPTION\_FAILED** **:** If encryption fails. Library returns `BayunErrorEncryptionFailed`.
* **ERROR\_DECRYPTION\_FAILED** **:** If decryption fails. Library returns `BayunErrorDecryptionFailed`.
* **ERROR\_GROUP\_DECRYPTION\_FAILED** **:** If the decryption fails for any component of the group. Library returns `BayunErrorGroupDecryptionFailed`.
* **ERROR\_ENCRYPTED\_DATA\_NOT\_FOUND** **:** If encrypted data is not found. Library returns `BayunErrorEncryptedDataNotFound`.
* **ERROR\_STORAGE\_KEY\_NOT\_FOUND\_IN\_RESPONSE** **:** If storage key is not found in the response. Library returns `BayunErrorStorageKeyNotFoundInResponse`.
* **ERROR\_GROUP\_KEY\_SIGNATURE\_FAILED** **:** If group key signature could not be generated. Library returns `BayunErrorGroupKeySignatureCouldNotBeGenerated`.
* **ERROR\_GROUP\_PRIVATE\_KEY\_SIGNATURE\_FAILED** **:** If group private key signature could not be generated. Library returns `BayunErrorGroupPrivateKeySignatureCouldNotBeGenerated`.
* **ERROR\_INVALID\_KEY\_PAIR** **:** If the app key pair is invalid. Library returns `BayunErrorInvalidAppKeyPair`.
* **INVALID\_KEY\_PAIR\_ID** **:** If the key pair id is invalid. Library returns `BayunErrorInvalidKeyPairId`.
* **ERROR\_ORG\_SETTINGS\_ROLLED\_BACK** **:** If server is compromised and org settings are rolled back, please inform the admin. Library returns `BayunErrorOrgSettingsRolledBack`.
* **ERROR\_ORG\_SETTINGS\_SIGNATURE\_INVALID** **:** If org settings signature is invalid. Library returns `BayunErrorOrgSettingsSignatureIsInvalid`.

**Organization and Application Errors**

* **ERROR\_INVALID\_ORG\_NAME** **:** If org name is invalid. Library returns `BayunErrorInvalidOrgName`.
* **INVALID\_ORG\_OR\_MEMBER\_NAME** **:** If the org or member name is invalid. Library returns `BayunErrorInvalidOrgOrMemberName`.
* **ERROR\_ORGANIZATION\_ALREADY\_EXISTS** **:** If an organization with this name already exists. Library returns `BayunErrorOrganizationAlreadyExists`.
* **ERROR\_ORG\_OR\_MEMBER\_OR\_MEMBERAPP\_ALREADY\_EXIST** **:** If the org, member, or member app already exists. Library returns `BayunErrorOrgOrMemberOrMemberAppAlreadyExist`.
* **ERROR\_INVALID\_APP\_ID** **:** If app id is invalid. Library returns `BayunErrorInvalidAppId`.
* **ERROR\_INVALID\_APP\_SECRET** **:** If the app secret provided is invalid. Library returns `BayunErrorInvalidAppSecret`.
* **ERROR\_APP\_NOT\_LINKED** **:** If app is not linked with Member Account, please link the app on Admin Panel. Library returns `BayunErrorAppNotLinked`.
* **APP\_NOT\_EXIST\_FOR\_ORG** **:** If the app is not linked to the Org, try to register your account with the App and wait for an Admin to approve. Library returns `BayunErrorAppNotExistForOrg`.
* **APP\_DOES\_NOT\_HAVE\_THE\_CORRECT\_ROLE** **:** App does not have permission to create a new Org. Check with your admin or the app-provider. Library returns `BayunErrorAppDoesNotHaveTheCorrectRole`.
* **ERROR\_MEMBER\_APP\_KEY\_PAIR\_ALREADY\_EXISTS** **:** If member app key pair already exists. Library returns `BayunErrorMemberAppKeyPairAlreadyExists`.
* **ERROR\_MEMBER\_APP\_NOT\_REGISTERED** **:** If a member account is not registered to use the App, first register and then try again. Library returns `BayunErrorMemberAppNotRegistered`.
* **ERROR\_MEMBER\_APP\_NOT\_EXIST\_FOR\_ID** **:** If the member app does not exist for the given member app id. Library returns `BayunErrorMemberAppDoesNotExistForGivenMemberAppId`.
* **ERROR\_MEMBER\_PUBLIC\_KEY\_NOT\_EXISTS** **:** If the member public key does not exist. Library returns `BayunErrorMemberPublicKeyDoesNotExist`.
* **ERROR\_USER\_NOT\_ASSOCIATED\_WITH\_MEMBER** **:** If no user is associated with the given member app id. Library returns `BayunErrorNoUserAssociatedWithTheGivenMemberAppId`.
* **ERROR\_MEMBER\_LOCK\_BOX\_NOT\_FOUND\_FOR\_MEMBER** **:** If the member lock box is not found for the member. Library returns `BayunErrorMemberLockBoxNotFoundForMember`.
* **ERROR\_MEMBER\_CREATION\_APP\_KEY\_PAIR\_ID\_REQUIRED** **:** App is not allowed to register with, or create, a new member. Check with your admin or the app-provider. Library returns `BayunErrorMemberCreationAppKeyPairIdRequired`.

**Member and User Lifecycle Errors**

* **ERROR\_USER\_INACTIVE** **:** If member Status is Inactive. Library returns `BayunErrorUserInActive`.
* **ERROR\_MEMBER\_NOT\_APPROVED\_YET** **:** If account is registered but not approved yet, wait for your admin to approve and try logging in (do not register again). Library returns `BayunErrorMemberNotApprovedYet`.
* **ERROR\_MEMBER\_AUTHORIZATION\_IS\_PENDING** **:** If member authorization is pending. Library returns `BayunErrorMemberAuthorizationIsPending`.
* **ERROR\_MEMBER\_DOESNT\_EXIST** **:** If the member does not exist. Library returns `BayunErrorMemberDoesNotExist`.
* **ERROR\_MEMBERS\_DOESNT\_EXIST** **:** If the members do not exist. Library returns `BayunErrorMembersDoesNotExist`.
* **ERROR\_USER\_ALREADY\_EXISTS** **:** If the developer tries to register a user that already exists. Library returns `BayunErrorUserAlreadyExists`.
* **ERROR\_MEMBER\_ALREADY\_EXISTS** **:** If the member already exists. Library returns `BayunErrorMemberAlreadyExists`.
* **ERROR\_MEMBER\_ALREADY\_EXISTS\_FOR\_A\_DIFFERENT\_EMAIL\_ADDRESS** **:** If the member already exists for a different email address. Library returns `BayunErrorMemberAlreadyExistsForADifferentEmailAddress`.
* **ERROR\_MEMBER\_CREATION\_NOT\_ALLOWED** **:** If member creation is not allowed. Library returns `BayunErrorMemberCreationNotAllowed`.
* **ERROR\_USER\_DOSE\_NOT\_EXISTS** **:** If the user does not exist for the given email. Library returns `BayunErrorUserDoesNotExist`.
* **ERROR\_REGISTRATION\_INCOMPLETE** **:** If user registration is incomplete (user does not exist for given email). Library returns `BayunErrorRegistrationIncomplete`.
* **ERROR\_USER\_HAVE\_NO\_ACTIVE\_MEMBERS** **:** If the user has no active members. Library returns `BayunErrorUserHaveNoActiveMembers`.

**Group and Participant Errors**

* **ERROR\_GROUP\_ID\_CANNOT\_BE\_NULL** **:** If GroupId is null. Library returns `BayunErrorGroupIdCannotBeNull`.
* **ERROR\_INVALID\_GROUP\_ID** **:** If groupId does not exist for GroupId. Library returns `BayunErrorGroupDoesNotExistsForGroupId`.
* **ERROR\_GROUP\_DOES\_NOT\_EXIST** **:** If the group does not exist. Library returns `BayunErrorGroupDoesNotExist`.
* **ERROR\_MEMBER\_DOESNT\_BELONG\_TO\_GROUP** **:** If member does not belong to Group. Library returns `BayunErrorMemberDoesNotExistForGroupId`.
* **ERROR\_PARTICIPANT\_EXISTS\_IN\_GROUP** **:** If participant already exists in the Group. Library returns `BayunErrorParticipantAlreadyExistsInGroup`.
* **ERROR\_CANNOT\_JOIN\_PRIVATE\_GROUP** **:** If participant tries to join a private Group. Library returns `BayunErrorCannotJoinPrivateGroup`.
* **ERROR\_NO\_GROUP\_PARTICIPANTS\_IN\_THE\_PARAMETERS** **:** If no group participants are found in the parameters. Library returns `BayunErrorNoGroupParticipantsInTheParameters`.
* **ERROR\_MEMBER\_NOT\_AUTHORIZED\_TO\_CREATE\_GROUPS** **:** If the member is not authorized to create groups. Library returns `BayunErrorMemberNotAuthorizedToCreateGroups`.
* **AUTO\_APPROVED\_MEMBER\_ACCESS\_DENIED** **:** Auto-approved members do not have access to this operation; ask your admin to approve you. Library returns `BayunErrorAutoApprovedMemberAccessDenied`.
* **AUTO\_APPROVED\_MEMBER\_CANNOT\_ADD\_TO\_GROUP** **:** Auto-approved members cannot add members to a group. Library returns `BayunErrorAutoApprovedMemberCannotAddToGroup`.
* **CANNOT\_ADD\_AUTO\_APPROVED\_MEMBER\_TO\_GROUP** **:** Auto-approved members cannot be added to a group. Library returns `BayunErrorCannotAddAutoApprovedMemberToGroup`.
* **CANNOT\_ADD\_MEMBER\_FROM\_OTHER\_ORG** **:** Members from other organizations cannot be added to the group. Library returns `BayunErrorCannotAddMemberFromOtherOrg`.
* **ERROR\_ORG\_VALIDATION\_POLICY\_DOES\_NOT\_ALLOW\_THIS\_OPERATION** **:** If the org validation policy does not allow this operation. Library returns `BayunErrorYourOrgValidationPolicyDoesNotAllowThisOperation`.

**Security Questions and Recovery Errors**

* **ERROR\_AT\_LEAST\_THREE\_ANSWERS\_REQUIRED** **:** If user answers less than three security questions. Library returns `BayunErrorAtleastThreeAnswersRequired`.
* **ERROR\_INCORRECT\_ANSWERS** **:** If user has provided wrong answers for one or more security questions. Library returns `BayunErrorIncorrectAnswers`.
* **ERROR\_INCOMPLETE\_SECURITY\_QUESTIONS** **:** If the developer provides incomplete data for set security question. Library returns `BayunErrorIncompleteSecurityQuestions`.
* **ERROR\_INVALID\_K\_N\_VALUES** **:** Total questions (N) must be between 2 and 10; minimum correct required (K) must be between 2 and N. Library returns `BayunErrorInvalidKNValues`.
* **ERROR\_USER\_RECOVERY\_ALREADY\_IN\_PROGRESS** **:** If user recovery is already in process, please contact your admin. Library returns `BayunErrorUserRecoveryAlreadyInProgress`.
* **ERROR\_ACCOUNT\_IN\_RECOVERY\_MODE** **:** This account is currently in recovery mode. Please use the Bayun Admin Panel to complete account recovery. Library returns `BayunErrorAccountInRecoveryMode`.

**Face Recognition and Input Validation Errors**

* **ERROR\_INCORRECT\_SECRET** **:** If secret for face recognition model does not match. Library returns `BayunErrorIncorrectSecret`.
* **ERROR\_FACE\_RECOGNITION\_IS\_DISABLED\_FOR\_THIS\_DOMAIN** **:** If face recognition is disabled for this domain, please use enableFaceRecognition as false. Library returns `BayunErrorFaceRecognitionIsDisabledForThisDomain`.
* **ERROR\_CANNOT\_SET\_PARAMETER\_REGISTER\_FACE\_ID\_TO\_TRUE\_AS\_ENABLE\_FACE\_RECOGNITION\_IS\_SET\_TO\_FALSE** **:** If enableFaceRecognition is set to false, the registerFaceId parameter cannot be set to true. Library returns `BayunErrorCannotSetParameterRegisterFaceIdToTrueAsEnableFaceRecognitionIsSetToFalse`.
* **ERROR\_NOT\_A\_VALID\_EMAIL** **:** If the provided email is not valid. Library returns `BayunErrorNotAValidEmail`.

**Email OTP Errors**

* **ERROR\_INVALID\_OTP** **:** If the entered OTP is incorrect. Library returns `BayunErrorInvalidOtp`.
* **ERROR\_OTP\_EXPIRED** **:** If the OTP has expired. Library returns `BayunErrorOtpExpired`.
* **ERROR\_TOO\_MANY\_INCORRECT\_OTP\_ATTEMPTS** **:** If too many incorrect OTP attempts were made. Library returns `BayunErrorTooManyIncorrectOtpAttempts`.
* **ERROR\_PLEASE\_WAIT\_BEFORE\_REQUESTING\_ANOTHER\_OTP** **:** If another OTP is requested too soon. Library returns `BayunErrorPleaseWaitBeforeRequestingAnotherOtp`.
* **ERROR\_EMAIL\_OTP\_NOT\_VERIFIED** **:** If email OTP has not been verified. Library returns `BayunErrorEmailOtpNotVerified`.
* **ERROR\_OTP\_SEND\_FAILED** **:** If sending the OTP email failed. Library returns `BayunErrorOtpSendFailed`.
* **ERROR\_OTP\_REQUIRED** **:** If OTP is required to continue registration (for example `verifyEmailOtpAndRegister` was called without `otp`). Library returns `BayunErrorOtpRequired`.

**Generic and System Errors**

* **ERROR\_SOMETHING\_WENT\_WRONG** **:** If error is unknown. Library returns `BayunErrorSomethingWentWrong`.
* **ERROR\_TOKEN\_NOT\_FOUND** **:** If the token is not found. Library returns `BayunErrorTokenNotFound`.
