question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Have a unique error code for each error message

See original GitHub issue

Goals

Be able to distinguish authentication errors by their code.

Expected Results

Have a unique error code for every error message.

Actual Results

When logging in realm with a JWT token, I can receive the following error codes (among others):

{code:46, message: "user disabled"}
{code:47, message: "(something about authentication failed...) ; token is expired"}
{code:47, message: "failed to lookup key for kid=..."}

The last one occurs when I try to log in my production realm with a staging JWT, for instance.

It doesn’t seem logic to me to have the same error code for two different errors, especially since my app should behave differently in case I get a 47 error code:

  • “failed to lookup…” => logout, clear token cache
  • “token expired” => renew token, then retry to log in Realm

Version of Realm and Tooling

  • Realm JS SDK Version: 10.0.0-rc.1
  • Node or React Native: React Native
  • Client OS & Version: macOS 10.15.7
  • Which debugger for React Native: None

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
knethcommented, Oct 7, 2020

@euZebe The docs team will soon create complete list of error codes with some guidance of error handling.

0reactions
euZebecommented, Nov 22, 2021

I got the failed to lookup key for kid error again ; it went from the fact that I can switch between staging and production environments in my app, then I can switch between two realms app. The error happens when I accidently try to open the staging realm app instead of the production realm app. In my opinion, it would be great to update the error message: failed to lookup key for kid=... ; perhaps you are trying to open the wrong realm app ID.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why different error codes for same Exception? - Stack Overflow
I am doing one synchronization example. I got two exceptions which are having same details about exception. But with the error codes. And...
Read more >
Your own error code | Andrzej's C++ blog - WordPress.com
I was recently implementing the "classification of error conditions" in my application offered by the functionality behind std::error_code.
Read more >
Hulu Error Codes: What They Are and How to Fix Them
There are dozens of different Hulu error codes and Hulu error messages aren't always crystal clear in terms of explaining the problem.
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
Custom errors, extending Error - The Modern JavaScript Tutorial
The Apple error objects have a unique code and message property assigned to the error objects. Similarly on JS, an application can add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found