Thanks Malcom. Actually somebody in the IRC showed me how to do exactly what I want with this:
if the_thing != the_other_thing: raise StandardError ('This function doesn't work. Please fix it.') Does exactly what I wanted :-) Thanks guys! Sean On Sep 16, 2006, at 8:15 PM, Malcolm Tredinnick wrote: > > On Sat, 2006-09-16 at 19:10 +0900, Sean Schertell wrote: >> Maybe I'm going about this the wrong way. All I want to do is exit >> the script and barf a big ugly error to the screen or the log in the >> event that something uncool happens. >> >> So for example, let's say in my view I have a function to calculate >> area: >> >> def calculate_area(width, height): >> if not width and height: >> raise ('Unable to calculate area -- missing parameters') >> else: >> return width * height >> >> But then I just get a nasty 500 error (using apache/mod_python in dev >> mode) and my error string doesn't get displayed or logged anywhere >> either. > > The return from a view must be an HttpResponse or derivative instance. > If you want something to go to the your server error logs, then > normally > you would send it to sys.stderr. In that case, you still need to > return > an HttpResponse from your view, since that controls what is sent > back to > the client. > > Django has one shortcut here, which is that you can raise a > django.http.Http404 exception for a missing page. But for all other > status codes, either create your own HttpResponse instance (setting > the > status_code attribute to whatever you want), or use one of the > pre-defined ones from django/http/__init__.py, such as > HttpResponseServerError, and return that (note *return*, not *raise*). > > Regards, > Malcolm > > > > > > > :::: DataFly.Net :::: Complete Web Services http://www.datafly.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---