How could i know all about error codes?

when i request email registerUser api with already existing email address, i’ve got below error response.

{"error":"name already in use","error_code":"AccountNameInUse","link":""}

and then, i’m wondering if i could know all error responses in advance, i think we could develop our code more carefully.

i need your some advice. thank you

Not sure if this is what you’re looking for but here are some links I found with lists of error codes for Realm.

MongoDB realm sync errors

Github list of errors for Realm

1 Like

Hey Aiden, welcome to the forums! :wave:

Unfortunately I don’t think we have documentation on all of the errors you might encounter across all of Realm’s app services. The links that Eli posted only include errors related to Realm Sync so you won’t find anything for the email/password auth error you encountered.

Would something like the Sync Errors page for the other types of errors be useful for you? We’d be happy to add this to the docs though I can’t guarantee a timeline.

In the meantime, hopefully this code (adapted from the web tutorial) covers your needs for email/password auth:

function handleAuthenticationError(err) {
  const handleUnknownError = () => {
      "Something went wrong with a Realm login or signup request. See the following error for details."
  if (err instanceof Realm.MongoDBRealmError) {
    const { error, statusCode } = err;
    const errorType = error || statusCode;
    switch (errorType) {
      case "invalid username":
        // Invalid email address
      case "invalid username/password":
      case "invalid password":
      case 401:
        // Invalid password
      case "name already in use":
      case 409:
        // Email is already registered
      case "password must be between 6 and 128 characters":
      case 400:
        // Invalid password - must be between 6 and 128 characters
        // In theory you won't ever hit this default, but if an error message/code without a case ever comes up it will fall back to this.
  } else {
    // In this case, the error isn't a MongoDB Realm error so you probably need to add another error handler somewhere else to catch it before it gets passed to this function.

Thanks for the reply :slight_smile:

email/password errors are so awesome answer we wanted, i appreciate it!
and furthermore, if mongo realm provides various error status docs we’d be so happy.
mongo DB, atlas and realm-web are our team’s primary development stack :smiling_face_with_three_hearts:


Glad it helped! I’ll look into getting some new error docs scheduled for work soon.


Hi @nlarew ! Do you have some news about adding all error_code of realm web in documentation ?

1 Like

Hey everyone! We’re still interested in creating better documentation around errors and how to handle them. Realm is a big product, so it’ll be easier for us to plan and ship docs if we know where you’d find them most helpful.

Are there specific use cases where you’re especially interested in handling errors from your web or mobile apps?

e.g. The code example I posted earlier in this thread shows error codes/messages & how to handle them when you’re doing email/password authentication.

Are you interested in docs for other auth provider errors? Or other app services that you use like rules, schemas, functions, etc? What about server-side only services like triggers, webhooks, http endpoints, etc?

Thanks in advance for any answers!


i’m waiting with patience for all about error documents which include app services and server-side services. :nerd_face:
thanks your support!

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