Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

unable to catch errors.... #479

Closed
bedspax opened this Issue Oct 3, 2012 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

bedspax commented Oct 3, 2012

Hi guys, this is my view for LOGIN_ERROR_URL:

def process_login_errors(request):
from django.contrib.messages.api import get_messages
messages = get_messages(request)
for message in messages:
print message
return HttpResponse('BAD JOKE')

it print only:
True
True

Why?

Contributor

bedspax commented Oct 3, 2012

I thinks the problem is here:

else:
    msg = setting('LOGIN_ERROR_MESSAGE', None)
    if msg:
        messages.error(request, msg)
    url = backend_setting(backend, 'LOGIN_ERROR_URL', LOGIN_ERROR_URL)

@omab

Ok, gotcha. The problem is that i Have set LOGIN_ERROR_MESSAGE = True.

But I would want to know why there are this login error.. :)

Owner

omab commented Oct 3, 2012

That code will run when user is None for some reason, it didn't authenticated, or something else, it's not clear actually and shouldn't happen often IMO, that's why DSA uses exceptions to raise real errors. LOGIN_ERROR_MESSAGE is just a fancy text to show in that case, doesn't aim to be per-issue solution. Maybe you could track where the user becomes None in the pipeline or the auth process and raise an exception there. I'll gladly merge a pull request with that change :D

Contributor

bedspax commented Oct 5, 2012

Thanks @omab as always. It's a my bad error on my custom pipeline. ;)

@bedspax bedspax closed this Oct 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment