Re: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Jani Tiainen
Also I would suggest that you log exception in case you don't want to raise
it. That way you know that something goes wrong.

12.8.2017 18.52 "Fellipe Henrique"  kirjoitti:

> Thanks, but.. it's  weird I tried that before, and show me the error, but,
> only text.. not that "yellow page" from django...
>
> I'll look again my code...
>
> Thanks again!
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> On Sat, Aug 12, 2017 at 12:32 PM, Marcin Gałązka 
> wrote:
>
>> > Hello,
>> >
>> > i have these code, for example:
>> >
>> > try:
>> >x = parse_date('')
>> > except TypeError:
>> >   return False
>> >
>> ​>
>> >
>> >  It's ok for me code like these.. but, when DEBUG == True, I like to
>> show the django default error page...
>> >
>> > How can I do that?
>> >
>> > Regards
>>
>> Why not simply re-raise the exception?
>>
>> from yourproject.settings import DEBUG
>>
>> try:
>>   x = parse_date('')
>> except TypeError:
>>   if DEBUG:
>> raise
>>   return False
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/VI1PR03MB10060FE0FF9D5AA3E8CFF7D0D98E0%
>> 40VI1PR03MB1006.eurprd03.prod.outlook.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAF1jwZF1-ngef_bJjR943yM0KeNjo0LYvHjat_
> p3hu%2B8Qjnodw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oc4ZQwTOiuj1%2BnPCwcCPqAMSskcu52P7iyOgj43yqYPdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Fellipe Henrique
Thanks, but.. it's  weird I tried that before, and show me the error, but,
only text.. not that "yellow page" from django...

I'll look again my code...

Thanks again!

T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

On Sat, Aug 12, 2017 at 12:32 PM, Marcin Gałązka 
wrote:

> > Hello,
> >
> > i have these code, for example:
> >
> > try:
> >x = parse_date('')
> > except TypeError:
> >   return False
> >
> ​>
> >
> >  It's ok for me code like these.. but, when DEBUG == True, I like to
> show the django default error page...
> >
> > How can I do that?
> >
> > Regards
>
> Why not simply re-raise the exception?
>
> from yourproject.settings import DEBUG
>
> try:
>   x = parse_date('')
> except TypeError:
>   if DEBUG:
> raise
>   return False
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/VI1PR03MB10060FE0FF9D5AA3E8CFF7D0D98E0%40VI1PR03MB1006.
> eurprd03.prod.outlook.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF1jwZF1-ngef_bJjR943yM0KeNjo0LYvHjat_p3hu%2B8Qjnodw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Marcin Gałązka
> Hello,
> 
> i have these code, for example:
> 
> try:
>x = parse_date('')
> except TypeError:
>   return False
>
​>
>
>  It's ok for me code like these.. but, when DEBUG == True, I like to show the 
> django default error page...
> 
> How can I do that?
> 
> Regards

Why not simply re-raise the exception?

from yourproject.settings import DEBUG

try:
  x = parse_date('')
except TypeError:
  if DEBUG:
raise
  return False

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/VI1PR03MB10060FE0FF9D5AA3E8CFF7D0D98E0%40VI1PR03MB1006.eurprd03.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Vijay Khemlani
from django.conf import settings

try:
   x = parse_date('')
except TypeError:
  if settings.DEBUG:
raise
  else:
return False


On Sat, Aug 12, 2017 at 10:54 AM, Fellipe Henrique 
wrote:

> Hello,
>
> i have these code, for example:
>
> try:
>x = parse_date('')
> except TypeError:
>   return False
>
> ​
>
>  It's ok for me code like these.. but, when DEBUG == True, I like to show
> the django default error page...
>
> How can I do that?
>
> Regards
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAF1jwZF%2Bf2KAZjNWA%2BjVnhTKbSj-
> vQQ4WjQRUzsr5vCxrqg4Eg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2t6xh3zjHBbuVC_rjZmw6csnBRQ1gxY7tX-y3741tg_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Jani Tiainen
You can reraise exception simply by calling "raise" without params.

12.8.2017 17.54 "Fellipe Henrique"  kirjoitti:

> Hello,
>
> i have these code, for example:
>
> try:
>x = parse_date('')
> except TypeError:
>   return False
>
> ​
>
>  It's ok for me code like these.. but, when DEBUG == True, I like to show
> the django default error page...
>
> How can I do that?
>
> Regards
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAF1jwZF%2Bf2KAZjNWA%2BjVnhTKbSj-
> vQQ4WjQRUzsr5vCxrqg4Eg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofJjr2ky-xnYsB%2BV6eyTZ8D_0wxsBGK5YwgN6QxWArzEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.