Next-auth: Improved error handling

Created on 21 Apr 2020  路  7Comments  路  Source: nextauthjs/next-auth

Thanks for the update. I was hesitant to access the next-auth routes manually but was able to signin as you suggested above successfully.

One follow-up question, though. Is there a way to capture errors thrown in the next-auth.functions signin() method? For example, if signin() fails, next-auth redirects to error.js and passes '/auth/error?action=signin&type=credentials' in the query string. Is there a way to capture more detailed information regarding the failure - perhaps the error originally thrown during signin()??

_Originally posted by @DomenicoCammarota in https://github.com/iaincollins/next-auth/issues/45#issuecomment-417373260_

enhancement question

Most helpful comment

Okay so this has been added with #222, however @iaincollins I just wanted to remind you, the errors docs page needs filling out eventually. Currently I only have one of the errors descriptions written out.

I've gathered all the named errors I could find in the application in the document already, they just need descriptions now. See: https://next-auth.js.org/errors or www/docs/errors.md. Some of them are pretty obvious as to what the error is and I can help you write those, but others you're going to have to decipher haha

All 7 comments

Hi @adeshkumar1201,

Short answer, no there isn't.

I've just made an announcement about version 2.0 which should drop later this month.

It's much simpler to configure and this is definitely something that should be address in 2.x - if not at release, then it should be on the roadmap for 2.1.

Moving this into version 2.0 milestone as this needs to be addressed.

There is a chance this will slip into a subsequent release (e.g. v2.1) but the issue is still relevant.

@iaincollins I saw you mention somewhere you'd like to have URLs to the docs in the error messages. I like this idea a lot too and I noticed you have error codes for most things already built in (i.e. CLIENT_USE_SESSION_ERROR.)

Maybe we could use redirects to get those error messages to point to the right page, i.e. next-auth.js.org/err/CLIENT_USE_SESSION_ERROR could point to the client page. And we could append these to the end of the error output on the console.

If your into the idea, I could take a look at this a little further.

Yes, I would love that! I am a huge fan of errors that point to a URL.

Maybe we could even make specific docs for each error so they are easy to link to and describe?

e.g.

https://next-auth.js.org/errors/CLIENT_USE_SESSION_ERROR -> www/docs/errors/CLIENT_USE_SESSION_ERROR.md?

Or I guess we could just have a single page for all errors and use anchor links, if that approach feels like overkill?

e.g.

https://next-auth.js.org/errors#CLIENT_USE_SESSION_ERROR

Either would be better than no documentation :D

Okay so this has been added with #222, however @iaincollins I just wanted to remind you, the errors docs page needs filling out eventually. Currently I only have one of the errors descriptions written out.

I've gathered all the named errors I could find in the application in the document already, they just need descriptions now. See: https://next-auth.js.org/errors or www/docs/errors.md. Some of them are pretty obvious as to what the error is and I can help you write those, but others you're going to have to decipher haha

@ndom91 Oh no how is _GET_OAUTH_ACCESS_TOKEN_ERROR a real error 馃檲

That list is great, thank you! I guess I have some cleaning up and documenting to do. :-)

We have excellent debug logging, a place for online documentation (and integration that directs users to the website when an error is logged) as well as new events system (which is great for audit logging), so I'm going to close this off as resolved.

We still need to expand on some of the errors and provide additional debug logging, but we now have the mechanisms to do that easily.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eatrocks picture eatrocks  路  3Comments

alex-cory picture alex-cory  路  3Comments

ryanditjia picture ryanditjia  路  3Comments

jimmiejackson414 picture jimmiejackson414  路  3Comments

benoror picture benoror  路  3Comments